Skip to content

Instantly share code, notes, and snippets.

@dwilliamson
dwilliamson / vsync.txt
Created November 30, 2015 22:44
Windows vsync
VSync under Windows, revisited
http://www.virtualdub.org/blog/pivot/entry.php?id=157
Windowed mode, vsync stutter, DWM (Vista+)
http://armageddongames.net/showthread.php?96793-Windowed-mode-vsync-stutter-DWM-(Vista-)
DwmFlush function
https://msdn.microsoft.com/en-us/library/windows/desktop/dd389405(v=vs.85).aspx
Bug 856427 - Add vsync support on windows
@gorlak
gorlak / tools-talks.md
Last active November 29, 2021 05:55
gamedev tools (and programming) talks
@cdwfs
cdwfs / cube-strip
Last active December 22, 2023 15:39
Rendering a cube as a 14-index triangle strip
; How to render a cube using a single 14-index triangle strip
; (Reposted from http://www.asmcommunity.net/forums/topic/?id=6284#post-45209)
; Drawbacks: no support for per-vertex normals, UVs, etc.
;
; 1-------3-------4-------2 Cube = 8 vertices
; | E __/|\__ A | H __/| =================
; | __/ | \__ | __/ | Single Strip: 4 3 7 8 5 3 1 4 2 7 6 5 2 1
; |/ D | B \|/ I | 12 triangles: A B C D E F G H I J K L
; 5-------8-------7-------6
; | C __/|
@paniq
paniq / minmaxabssign.txt
Last active January 30, 2023 14:31
useful min/max/abs/sign identities
max(-x,-y) = -min(x,y)
min(-x,-y) = -max(x,y)
abs(x) = abs(-x)
abs(x) = max(x,-x) = -min(x,-x)
abs(x*a) = if (a >= 0) abs(x)*a
(a < 0) -abs(x)*a
// basically any commutative operation
min(x,y) + max(x,y) = x + y
@dwilliamson
dwilliamson / SphereIndexing.glsl
Last active December 8, 2017 17:48
Given a 3D point on the sphere, map to a unique, sub-divided triangle index in O(1) with no recursive searching or table lookups.
// Some shitty boolean logic code because WebGL...
bool and(int x, int y)
{
return mod(float(x), exp2(float(y))) != 0.0;
}
int GetTriangleIndex(vec3 position)
{
// TODO: Add integer arithmetic to simplify the boolean logic.
@dwilliamson
dwilliamson / FileWatcher.cpp
Created January 22, 2015 21:39
Single-threaded file watcher with overlapped I/O and filtering of multiple notifications
class FileWatcher
{
public:
FileWatcher(const Path& path)
: m_Path(path)
, m_DirHandle(INVALID_HANDLE_VALUE)
, m_BufferSize(CORE_KB(100))
, m_Buffer(nullptr)
, m_ChangedFiles(1024)
{
Below I collected relevant links and papers more or less pertaining to the subject of tetrahedral meshes.
It's an ever-growing list.
------------------------------
Relevant links:
http://en.wikipedia.org/wiki/Types_of_mesh
http://en.wikipedia.org/wiki/Tetrahedron
http://en.wikipedia.org/wiki/Simplicial_complex
@rygorous
rygorous / iggy_focus.cpp
Created October 14, 2013 19:46
Iggy focus handling
enum FocusDir
{
DIR_W,
DIR_E,
DIR_N,
DIR_S
};
static FocusDir get_quadrant(float dx, float dy)
{
@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD