Skip to content

Instantly share code, notes, and snippets.

@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)
{
@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)
{
@sebbbi
sebbbi / FramentShaderWaveCoherency.txt
Last active November 28, 2018 15:51
FramentShaderWaveCoherency test shader (Vulkan 1.1)
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_KHR_shader_subgroup_basic : enable
#extension GL_KHR_shader_subgroup_ballot : enable
#extension GL_KHR_shader_subgroup_vote : enable
#extension GL_KHR_shader_subgroup_arithmetic : enable
layout(location = 0) out vec4 outColor;
//#define VISUALIZE_WAVES
// NOTE: We parse the constant table by hand since shadergen has to link against the
// Xenon (XBox 360) d3dx lib statically if Xbox builds are to be supported. That means
// we can't easily use non-Xenon D3DX from here.
// **** This part copy & pasted from D3DX headers (but it's a file format so it's consistent
// across versions)
//----------------------------------------------------------------------------
// D3DXSHADER_CONSTANTTABLE:
// -------------------------
@gorlak
gorlak / tools-talks.md
Last active November 29, 2021 05:55
gamedev tools (and programming) talks
@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
enum { BMAX = 32, BCUT = BMAX / 2, BHEIGHT = 6 };
typedef uint8_t BIndex;
struct BNode {
BIndex length;
Key keys[BMAX];
union {
BNode *children[BMAX];
Value values[BMAX];
@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
//
// TinyCRT, revamp and TinyWin support by Don Williamson, 2011
// Based on http://www.codeproject.com/KB/library/tlibc.aspx and LIBCTINY by Matt Pietrek
//
#pragma once
#ifdef USE_DEFAULT_CRT