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 / 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 / ease.odin
Last active July 15, 2024 14:12
Easings library ported to Odin
package ease
// Adapted from functions here: https://github.com/warrenm/AHEasing/blob/master/AHEasing/easing.c
// For previews go here: https://easings.net/
import "core:math"
Mode :: enum {
linear = 0,
quad_in,
@jakubtomsu
jakubtomsu / ldtk.odin
Last active April 22, 2023 11:51
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
@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 / 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")
@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"
@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 / 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/
package main
import "core:fmt"
import "core:mem"
import "core:os"
import "core:runtime"
import "core:strconv"
import "core:sys/windows"
import "core:time"