Skip to content

Instantly share code, notes, and snippets.

I do not come in peace; I am here on a mission. I wish to vanquish the angles and trig which run amok
To my knowledge, this seems to stem from the thought:

The user provides and requests angles, therefore my formulas should input and output angles

At the very least, this is untrue in that the user provides degrees and we compute with radians
But more pervasively, I argue that the formulas are first and foremost Geometric and not Trigonometric

@Boostibot
Boostibot / rdtsc.h
Last active May 3, 2025 03:17
cross platform/compiler/isa RDTSC frequency with platform specific fallback C/++
//so that the implementation compiles.
//If you are using this file as .h remove this
#define MODULE_IMPL_ALL
//rdtsc.h
#ifndef MODULE_TSC
#define MODULE_TSC
#ifdef __cplusplus
extern "C" {
@Boostibot
Boostibot / rdtsc_frequency.c
Last active February 1, 2025 00:12
Get RDTSC frequency on linux x86
//Combination of the following:
// original gist: https://gist.github.com/pmttavara/6f06fc5c7679c07375483b06bb77430c
// discussion here: https://hero.handmade.network/forums/code-discussion/t/7485-queryperformancefrequency_returning_10mhz_bug/2#23567
// dump_vdso_data.c: https://gist.github.com/mildsunrise/c63505931534bd3c0e143c0db8cad3f3
//
// Original license:
// SPDX-FileCopyrightText: © 2022 Phillip Trudeau-Tavara <[email protected]>
// SPDX-License-Identifier: 0BSD
// https://linux.die.net/man/2/perf_event_open
#include "friday.h"
Entry(InputWaveInfo)
{
wave_info *WaveInfo = (wave_info*)InputWaveInfo;
shared_wave_info *Shared = WaveInfo->Shared;
memory_arena Arena = {0};
Arena.Start = MemoryReserve(GigaBytes(64));
////////////////////////////////
// NBHS - Non-blocking hashset
////////////////////////////////
// You wanna intern lots of things on lots of cores? this is for you. It's
// inspired by Cliff's non-blocking hashmap.
//
// To use it, you'll need to define NBHS_FN and then include the header:
//
// #define NBHS_FN(n) XXX_hs_ ## n
// #include <nbhs.h>
@d7samurai
d7samurai / .readme.md
Last active March 19, 2025 21:29
Minimal D3D11 sprite renderer NEO

sponsored by SuperNeo copy 4

Minimal D3D11 sprite renderer NEO

Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes anchor/pivot point, rotation, color filtering, alpha blending and built-in antialiased point sampling. As usual: complete, runnable single-function app. ~150 LOC. No modern C++, OOP or (other) obscuring cruft.

Minimal D3D11 sprite renderer NEO 1337

Sprites are rendered back-to-front (AKA "painter's algorithm") in the order they are submitted, as one draw call. The provided setup employs a single texture atlas containing all the sprite graphics.

The renderer is "im

@Boostibot
Boostibot / win32_stack_trace.c
Last active February 2, 2025 23:51
win32 stack trace
#include <stdint.h>
typedef struct {
char function[256]; //mangled or unmangled function name
char module[256]; //mangled or unmangled module name ie. name of dll/executable
char file[256]; //file or empty if not supported
int64_t line; //0 if not supported
} Platform_Stack_Trace_Entry;
//Captures the current stack frame pointers.
//Saves up to stack_size pointres into the stack array and returns the number of
from typing import Optional, Tuple, Union, overload
_time_unit_map = {
"ps": -12,
"ns": -9,
"us": -6,
"ms": -3,
"s": 0,
}
@d7samurai
d7samurai / .readme.md
Last active April 21, 2025 20:02
Minimal WASAPI

Minimal WASAPI

Minimal WASAPI reference implementation. Runnable console application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft. Produces a steady sine wave sound.

(This is a re-post of the same gist I posted a few years earlier, simply due to me wanting the Minimal D3D11 series to be listed contiguously and it's not possible to hide or rearrange gists).

@mmozeiko
mmozeiko / tls_client.c
Last active March 21, 2025 15:58
simple example of TLS socket client using win32 schannel api
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#define SECURITY_WIN32
#include <security.h>
#include <schannel.h>
#include <shlwapi.h>
#include <assert.h>
#include <stdio.h>