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
@kpcftsz
kpcftsz / DropShadows.cpp
Last active January 6, 2024 17:52
K.I.S.S. Dear ImGui drop shadows - dead simple
/*
* This function assumes the existence of an active Dear ImGui window
*/
void RenderDropShadow(ImTextureID tex_id, float size, ImU8 opacity)
{
ImVec2 p = ImGui::GetWindowPos();
ImVec2 s = ImGui::GetWindowSize();
ImVec2 m = {p.x + s.x, p.y + s.y};
float uv0 = 0.0f; // left/top region
float uv1 = 0.333333f; // leftward/upper region
@d7samurai
d7samurai / .readme.md
Last active March 25, 2024 10:45
Minimal D3D11 sprite renderer

Minimal D3D11 sprite renderer

Minimal D3D11 sprite renderer: basic back-to-front sprite rendering reference code with example sprite sheet animation logic. As usual: Complete, runnable single-function app. No modern C++ / OOP / obscuring cruft.

adventurer

Swap out the sprite sheet with a font atlas for a lightweight GUI / text renderer. Clip individual sprites and glyphs by offsetting screenPos and atlasPos to top left corner of visible area and adjusting size accordingly (all values in pixels):

sprite.screenPos.x += 17;
sprite.screenPos.y += 10;

2019-05-18

Jonathan Blow on societal collapse

It's uncanny how closely this talk follows a line of reasoning I've been working on lately. If you're copied here, we may have discussed one or more of its aspects

https://www.youtube.com/watch?v=pW-SOdj4Kkk

(Jonathan Blow is an independent video game developer, speaking here at a conference in Moscow.)

@darbotron
darbotron / ExampleSettings.cs
Last active June 6, 2022 09:11
Super easily (and extensibly) add a project global settings asset to the Unity Editor's project settings panels and/or edit in a floating window
//
// GenericUnityEditorSettings by Alex 'darbotron' Darby
//
// License: https://opensource.org/licenses/unlicense
// TL;DR:
// 1) you may do what you like with it...
// 2) ...except blame me for any consequence of acting on rule 1)
//
using UnityEngine;
using UnityEditor;
@shawwn
shawwn / since2010.md
Created May 11, 2021 09:46
"What happened after 2010?"

This was a response to a Hacker News comment asking me what I've been up to since 2010. I'm posting it here since HN rejects it with "that comment is too long." I suppose that's fair, since this ended up being something of an autobiography.

--

What happened after 2010?

# 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)
@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
@d7samurai
d7samurai / .readme.md
Last active April 11, 2024 09:53
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.

@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__
@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"]]]) %>,