Skip to content

Instantly share code, notes, and snippets.

@pabloasanchez
pabloasanchez / framelimit.c
Created January 10, 2025 11:20
SDL2/C frame limiter
// From: https://cplusplus.com/forum/beginner/94946/
// By: https://cplusplus.com/user/Disch/
#define FPS 60
int frame_length = 1000 / FPS; // Number of ms between frames. 17 gives you approx 60 FPS (1000 / 60)
Uint32 next_frame; // Timestamp that next frame is to occur
int skipped_frames; // Number of frames we have skipped
@pabloasanchez
pabloasanchez / arena.md
Created February 23, 2025 23:39
Memory Arena in C (samulinatri.com/blog/memory-management)
@pabloasanchez
pabloasanchez / Bresenham Algorithms in C
Last active May 24, 2025 08:23 — forked from bert/README
Bresenham Algorithms in C
Some possible implementations of the Bresenham Algorithms in C.
The Bresenham line algorithm is an algorithm which determines which points in an
n-dimensional raster should be plotted in order to form a close approximation
to a straight line between two given points.
It is commonly used to draw lines on a computer screen, as it uses only integer
addition, subtraction and bit shifting, all of which are very cheap operations
in standard computer architectures.
It is one of the earliest algorithms developed in the field of computer graphics.
A minor extension to the original algorithm also deals with drawing circles.
@pabloasanchez
pabloasanchez / octree.c
Last active June 17, 2025 07:30
Octree in C
// A C port of the example at https://iq.opengenus.org/octree
#include <stdlib.h>
#include "octree.h"
Octree * octree_point(int x, int y, int z) {
Octree * p = malloc(sizeof(Octree));
p->point = malloc(sizeof(Point3D));
p->point->x = x;
################################################################################
# sox cheat sheet
################################################################################
# Example commands for the sox command-line audio processing tool,
# for manipulating or batch processing audio files.
################################################################################
# Daniel Jones <dan-web@erase.net>
################################################################################
################################################################################