Skip to content

Instantly share code, notes, and snippets.

@futureengine2
futureengine2 / gi.c
Last active May 14, 2024 13:26
Radiance Cascades 2d GI implementation
static void gi_on_gpu(u8* in_bitmap, int w, int h) {
#define num_cascades 7
static bool initialized;
static gpu_bindgroup_t texture_bindgroup[2];
static gpu_bindgroup_t cascade_uniform_bindgroup[num_cascades];
static gpu_bindgroup_t render_uniform_bindgroup;
static gpu_buffer_t vertex_buffer;
static gpu_buffer_t uniform_buffer;
static gpu_pipeline_t pipeline;
@d7samurai
d7samurai / .readme.md
Last active May 26, 2024 19:16
Minimal D3D11 sprite renderer

Minimal D3D11 sprite renderer

Minimal D3D11 sprite renderer: basic back-to-front sprite rendering reference code with example sprite sheet animation logic. As usual: Complete, runnable single-function app. No modern C++ / OOP / obscuring cruft.

adventurer

Swap out the sprite sheet with a font atlas for a lightweight GUI / text renderer. Clip individual sprites and glyphs by offsetting screenPos and atlasPos to top left corner of visible area and adjusting size accordingly (all values in pixels):

sprite.screenPos.x += 17;
sprite.screenPos.y += 10;
@cshenton
cshenton / block_allocator.odin
Last active March 25, 2024 00:45
Allocator based on Sebastian Aaltonen's Offset Allocator, for suballocating GPU heaps
package block_allocator
// Allocator based on Sebastian Aaltonen's Offset Allocator:
// https://github.com/sebbbi/OffsetAllocator/blob/main/offsetAllocator.cpp
import "core:fmt"
import "core:math/bits"
import "core:math/rand"
assert_allocator_layout_good :: proc(allocator: ^Block_Allocator) {
@terickson001
terickson001 / main.odin
Last active May 26, 2024 17:08
vulkan-tutorial example in Odin
import "shared:shaderc"
import "vendor:glfw"
import vk "vendor:vulkan"
MAX_FRAMES_IN_FLIGHT :: 2
Context :: struct
{
instance: vk.Instance,
@mmozeiko
mmozeiko / astar.h
Last active December 29, 2023 10:18
generic A* in C
// generic A* pathfinding
//
// INTERFACE
//
// mandatory macros
#ifndef ASTAR_POS_TYPE
#error ASTAR_POS_TYPE should specify position type
@endolith
endolith / WAV interpretation.md
Last active August 3, 2023 23:45
Interpretation of WAV file sample data and asymmetry

How to handle asymmetry of WAV data?

WAV files can store PCM audio (WAVE_FORMAT_PCM). The WAV file format specification says:

The data format and maximum and minimums values for PCM waveform samples of various sizes are as follows:

Sample Size Data Format Maximum Value Minimum Value
One to eight bits Unsigned integer 255 (0xFF) 0
Nine or more bits Signed integer i Largest positive value of i Most negative value of i
@koktoh
koktoh / QmkFirmwarePinMaps.md
Last active March 31, 2024 11:58
QMK Firmware pin maps

QMK Firmware pin maps

Pro Micro

18 pins

              ._|~~|_.
    D3 [Tx0] -|      |- [RAW]
    D2 [Rx1] -|      |- [GND]
       [GND] -|      |- [RST]
#include "freeverb.h"
#define undenormalize(n) { if (xabs(n) < 1e-37) { (n) = 0; } }
static inline float xabs(float n) {
return n < 0 ? -n : n;
}
@benob
benob / stbttf.h
Last active June 15, 2023 12:14
Example for using stb_truetype with SDL2 renderer. Only supports ASCII characters.
#ifndef __STBTTF_H__
#define __STBTTF_H__
#include <SDL2/SDL.h>
#include "stb_rect_pack.h"
#include "stb_truetype.h"
/* STBTTF: A quick and dirty SDL2 text renderer based on stb_truetype and stdb_rect_pack.
* Benoit Favre 2019
@mashingan
mashingan / crud_web.nim
Last active June 11, 2023 00:45
Simplistic crud example using Jester and Nim
# This example using
# Nim: 0.18.0
# Jester: 0.2.1
# Using Jester >= 0.3.0 is preferrable if your Nim version > 0.18.0
# In case you're using Jester >= 0.3.0, look the syntax different
# in its example because it's not backward compatible
import db_sqlite, asyncdispatch, json, strformat, strutils, sequtils
import jester