Skip to content

Instantly share code, notes, and snippets.

View thomashope's full-sized avatar
🍃
Walking in the woods.

Thomas Hope thomashope

🍃
Walking in the woods.
View GitHub Profile
@armornick
armornick / playwav.c
Created August 24, 2012 07:31
Play a sound with SDL2 (no SDL_Mixer)
#include <SDL2/SDL.h>
#define MUS_PATH "Roland-GR-1-Trumpet-C5.wav"
// prototype for our audio callback
// see the implementation for more information
void my_audio_callback(void *userdata, Uint8 *stream, int len);
// variable declarations
static Uint8 *audio_pos; // global pointer to the audio buffer to be played
@k-takata
k-takata / bash-completion-slowness-on-msys2.md
Created May 13, 2015 15:08
Bash-completion is very slow on MSYS2

Bash-completion is very slow on MSYS2

Bash-completion is very slow on MSYS2 when the current user is a domain user. This describes the cause and the solutions.

Cause

Expansion of ~* is very slow when you use a domain user. For example:

@itsoli
itsoli / .lldbinit
Created October 6, 2015 08:43
lldb data formatter
type summary add glm::vec2 --summary-string "x=${var.x}, y=${var.y}"
type summary add glm::vec3 --summary-string "x=${var.x}, y=${var.y}, z=${var.z}"
type summary add glm::vec4 --summary-string "x=${var.x}, y=${var.y}, z=${var.z}, w=${var.w}"
type summary add glm::quat --summary-string "x=${var.x}, y=${var.y}, z=${var.z}, w=${var.w}"
type summary add glm::mat2 --summary-string "${var.value[0].x}, ${var.value[0].y} | ${var.value[1].x}, ${var.value[1].y}"
type summary add glm::mat3 --summary-string "${var.value[0].x}, ${var.value[0].y}, ${var.value[0].z} | ${var.value[1].x}, ${var.value[1].y}, ${var.value[1].z} | ${var.value[2].x}, ${var.value[2].y}, ${var.value[2].z}"
type summary add glm::mat4 --summary-string "${var.value[0].x}, ${var.value[0].y}, ${var.value[0].z}, ${var.value[0].w} | ${var.value[1].x}, ${var.value[1].y}, ${var.value[1].z}, ${var.value[1].w} | ${var.value[2].x}, ${var.value[2].y}, ${var.value[2].z}, ${var.value[2].w} | ${var.value[3].x}, ${var.value[3].y}, ${var.value[3].z}, ${var.value[3].
@rygorous
rygorous / hb_stb_truetype.c
Last active October 31, 2023 00:45
HarfBuzz->stb_truetype
// ---- loading a font
static void load_font(void)
{
hb_blob_t *blob;
hb_face_t *face;
size_t filelen = 0;
void *filedata = stb_file("c:/windows/fonts/arial.ttf", &filelen);
if (filedata == 0) stbpg_fatal("Couldn't load font");
@idbrii
idbrii / botw-cedec2017.md
Last active May 16, 2024 14:56
An inline image version of Matt Walker's translation of CEDEC 2017 talks by Nintendo
@jamietre
jamietre / pc-rules.erb
Last active February 16, 2024 10:51
Karabiner Elements config to map home/end keys to PC-like behavior on MacOS X
{
"title": "MacOS -> PC Shortcuts",
"rules": [
{
"description": "Top/bottom of document (ctrl+home/ctrl+end)",
"manipulators": [
{
"type": "basic",
"from": <%= from("home", ["command"], ["any"]) %>,
"to": <%= to([["up_arrow", ["left_command"]]]) %>,
@sherjilozair
sherjilozair / sdl-sokol-sprite.c
Created June 9, 2018 14:05
Minimal sprite rendering example with SDL2 for windowing, sokol_gfx for graphics API using OpenGL 3.3 on MacOS
#include <OpenGL/gl3.h>
#include <SDL2/SDL.h>
#define SOKOL_IMPL
#define SOKOL_GLCORE33
#include <sokol_gfx.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define CODE(...) #__VA_ARGS__
@d7samurai
d7samurai / .readme.md
Last active May 31, 2024 15:26
Minimal D3D11

Minimal D3D11

Minimal D3D11 reference implementation: An uncluttered Direct3D 11 setup + basic rendering primer and API familiarizer. Complete, runnable Windows application contained in a single function and laid out in a linear, step-by-step fashion that should be easy to follow from the code alone. ~200 LOC. No modern C++, OOP or (other) obscuring cruft. View on YouTube

hollowcube

Also check out Minimal D3D11 pt2, reconfigured for instanced rendering and with a smaller, tighter, simplified overall code structure, or Minimal D3D11 pt3, with shadowmapping + showcasing a range of alternative setup and rendering techniques.

@mikhailov-work
mikhailov-work / turbo_colormap.c
Created August 15, 2019 23:04
Turbo Colormap Look-up Table
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Author: Anton Mikhailov
// The look-up tables contains 256 entries. Each entry is a an sRGB triplet.
float turbo_srgb_floats[256][3] = {{0.18995,0.07176,0.23217},{0.19483,0.08339,0.26149},{0.19956,0.09498,0.29024},{0.20415,0.10652,0.31844},{0.20860,0.11802,0.34607},{0.21291,0.12947,0.37314},{0.21708,0.14087,0.39964},{0.22111,0.15223,0.42558},{0.22500,0.16354,0.45096},{0.22875,0.17481,0.47578},{0.23236,0.18603,0.50004},{0.23582,0.19720,0.52373},{0.23915,0.20833,0.54686},{0.24234,0.21941,0.56942},{0.24539,0.23044,0.59142},{0.24830,0.24143,0.61286},{0.25107,0.25237,0.63374},{0.25369,0.26327,0.65406},{0.25618,0.27412,0.67381},{0.25853,0.28492,0.69300},{0.26074,0.29568,0.71162},{0.26280,0.30639,0.72968},{0.26473,0.31706,0.74718},{0.26652,0.32768,0.76412},{0.26816,0.33825,0.78050},{0.26967,0.34878,0.79631},{0.27103,0.35926,0.81156},{0.27226,0.36970,0.82624},{0.27334,0.38008,0.84037},{0.27429,0.39043,0.85393},{0.27509,0.40072,0.86692},{0.2757
# Add to ~/.bashrc
# call load_msenv [year] from a shell to load the enviroment
function load_msenv() {
local msversion_year=2019
if [ $# -gt 0 ]; then
msversion_year=$1
fi
case $msversion_year in
2017)