Skip to content

Instantly share code, notes, and snippets.

@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 June 24, 2024 08:00
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 / d3d11_speedtest.c
Last active March 25, 2024 01:04
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 November 10, 2023 14:59
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 <karl@zylinski.se> (Initial port)
//
@jakubtomsu
jakubtomsu / collision_3d.odin
Last active June 13, 2024 21:08
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:
@mmozeiko
mmozeiko / upng.h
Last active February 25, 2024 08:08
uncompressed png writer & reader
#pragma once
// uncompressed png writer & reader
// supports only 8-bit and 16-bit formats
// Performance comparison for 8192x8192 BGRA8 image (256MB)
// Compiled with "clang -O2", AVX2 requires extra "-mavx2" or "/arch:AVX2" argument
//
// For libpng (compressed) uses default libpng/zlib compression settings
// For libpng (uncompressed) case following two functions are used: