Skip to content

Instantly share code, notes, and snippets.

@jakubtomsu
jakubtomsu / vscode_keybindings.json
Created November 14, 2022 11:58
My keybindings for VS Code
// Place your key bindings in this file to override the defaultsauto[]
[
{ "key": "ctrl+alt+p",
"command": "workbench.action.showCommands"
},
{ "key": "ctrl+shift+up",
"command": "cursorMove",
"args": {
"to": "prevBlankLine",
"select": true
@jakubtomsu
jakubtomsu / packchan.odin
Last active October 19, 2023 13:23
A simple command line utility for packing channels from multiple textures into one image.
// pachchan
// A simple command line utility for packing channels from multiple textures into one image.
// The implementation is kind of a hack :P
package packchan
import "core:os"
import "core:fmt"
import "core:strings"
import "core:strconv"
import "core:path/filepath"
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 / vlsm.odin
Created May 14, 2024 10:17
Simple Variable Length Subnet Mask solver
package vlsm
import "core:fmt"
import "core:intrinsics"
import "core:net"
import "core:slice"
Subnet :: struct {
prefix: u8,
num_hosts: u32,
@jakubtomsu
jakubtomsu / pathtest.c
Created August 2, 2023 14:55
Simple program for testing known folder paths on windows, e.g. for storing savegames.
// This is a small program to print a number of known paths in Windows.
// Savegame files should be in FOLDERID_SavedGames!
// SHGetKnownFolderPath should probably be used only for compatibility.
//
// Compile with `cl pathtest.c`
//
// Day created: 02.08.2023
// Version: Windows 10 pro 22H2
//
// Output on my machine:
@jakubtomsu
jakubtomsu / bitarray.h
Last active July 15, 2024 14:13
Super simple single-header bitarray example in C
// Simple bitarray example
// -----------------------
// Warning: no bounds checking
// Usually I'd use 'uint8_t' instead of an 'char' and 'size_t' instead of an 'int',
// but this way it can be copied anywhere without worrying about includes.
static inline int bitarray_get(const char* bitarray, const int index) {
return ((bitarray[index / 8]) >> (index % 8)) & 1;
}
@jakubtomsu
jakubtomsu / points_along_curve.odin
Created September 14, 2024 16:11
Simple example of nicely animating moving points along a curve
package curve_test
import "core:math/linalg"
import rl "vendor:raylib"
main :: proc() {
rl.SetConfigFlags({.MSAA_4X_HINT, .VSYNC_HINT})
rl.InitWindow(900, 600, "Curves")
defer rl.CloseWindow()
@jakubtomsu
jakubtomsu / qmap.odin
Created October 6, 2024 09:33
Very simple parser for quake .map readable level data format (Valve version). I didn't fully test it.
package qmap
import "core:fmt"
import "core:os"
import "core:strconv"
import "core:strings"
// https://developer.valvesoftware.com/wiki/MAP_(file_format)
File :: struct {
@jakubtomsu
jakubtomsu / ldtk.odin
Last active November 28, 2024 03:28
LDtk project importer for Odin
package ldtk
import "core:encoding/json"
import "core:os"
import "core:fmt"
load_from_file :: proc(filename: string, allocator := context.allocator) -> Maybe(Project) {
data, ok := os.read_entire_file(filename, allocator)
if !ok {
return nil
Renderer_Frustum :: struct {
planes: [6]Vec4,
}
renderer_frustum_from_projection_mat4 :: proc(m: Mat4) -> (result: Renderer_Frustum) {
// https://iquilezles.org/articles/frustum/
result.planes = {
{m[0, 3] - m[0, 0], m[1, 3] - m[1, 0], m[2, 3] - m[2, 0], m[3, 3] - m[3, 0]},
{m[0, 3] + m[0, 0], m[1, 3] + m[1, 0], m[2, 3] + m[2, 0], m[3, 3] + m[3, 0]},
{m[0, 3] + m[0, 1], m[1, 3] + m[1, 1], m[2, 3] + m[2, 1], m[3, 3] + m[3, 1]},