Skip to content

Instantly share code, notes, and snippets.

@runevision
runevision / BurstSDFGenerator.cs
Created September 11, 2024 07:48
Signed Distance Field generator for Unity with Burst support
/*
Based on the Anti-aliased Euclidean distance transform described by Stefan Gustavson and
Robin Strand. For further information, see https://contourtextures.wikidot.com/ and
https://web.archive.org/web/20220503051209/https://weber.itn.liu.se/~stegu/edtaa/
The algorithm is an adapted version of Stefan Gustavson's code, it inherits the copyright
statement below, which applies to this file only.
The rewrite with Unity Burst support makes the execution 40 times faster by default,
and 75 times faster if the passed in textures are both of type TextureFormat.RGBAFloat.
@laytan
laytan / renderer.odin
Last active July 15, 2024 16:36
Example Odin font renderer using fontstash and WebGPU
package vendor_wgpu_example_fontstash
import intr "base:intrinsics"
import "core:fmt"
import "core:math/linalg"
import sa "core:container/small_array"
import fs "vendor:fontstash"
import "vendor:wgpu"
@harold-b
harold-b / bgfx.odin
Created May 21, 2024 18:50
Odin bindings for bgfx
package bgfx
import "base:intrinsics"
import "base:runtime"
import cffi "core:c"
when ODIN_OS == .Linux {
@require foreign import bgfx {
"libs/windows/bgfx.a",
}
@laytan
laytan / main.odin
Last active September 10, 2024 15:27
Graphviz Odin dependencies
package main
import "core:fmt"
import "core:io"
import "core:odin/ast"
import "core:odin/parser"
import "core:os"
import "core:path/filepath"
import "core:slice"
import "core:strings"
@cshenton
cshenton / tri.c
Last active October 11, 2024 03:29
Seeing how fast a d3d11 swapchain can go.
#include <assert.h>
#include <stdio.h>
#include <time.h>
#define COBJMACROS
#include <windows.h>
#include <d3d11_1.h>
#include <d3dcompiler.h>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
package main
import "core:fmt"
import "core:mem"
import "core:os"
import "core:runtime"
import "core:strconv"
import "core:sys/windows"
import "core:time"
@jakubtomsu
jakubtomsu / octviz.odin
Last active November 20, 2023 11:11
Odin program for visualizing spherical/hemispherical octahedral mapping with Raylib
// Octahedral mapping visualization in Odin and Raylib
// by Jakub Tomšů (@jakubtomsu_)
//
// Build and run with 'odin run octsphere.odin -file'.
// No additional dependencies required.
//
// Sources:
// https://gpuopen.com/learn/fetching-from-cubes-and-octahedrons/
// https://knarkowicz.wordpress.com/2014/04/16/octahedron-normal-vector-encoding/
@jakubtomsu
jakubtomsu / d3d12_triangle.odin
Last active October 11, 2024 14:39
Simple d3d12 triangle example in Odin
// D3D12 single-function triangle sample.
//
// Usage:
// - copy SDL2.dll from Odin/vendor/sdl2 to your project directory
// - odin run .
//
// Contributors:
// - Jakub Tomšů (updated to newest Odin version)
// - Karl Zylinski <[email protected]> (Initial port)
//
@jakubtomsu
jakubtomsu / collision_3d.odin
Last active October 8, 2024 09:04
Simple raylib example of 3d FPS player movement with triangle collision
package main
import "core:fmt"
import "core:math"
import "core:math/linalg"
import rl "vendor:raylib"
main :: proc() {
rl.SetConfigFlags({.VSYNC_HINT, .WINDOW_RESIZABLE, .MSAA_4X_HINT})
rl.InitWindow(800, 600, "collision")
Complete stuff:
https://xmonader.github.io/letsbuildacompiler-pretty/
Lexers + DFAs:
https://gist.github.com/pervognsen/218ea17743e1442e59bb60d29b1aa725
Parsing:
https://eli.thegreenplace.net/2012/08/02/parsing-expressions-by-precedence-climbing
Backend: