Instantly share code, notes, and snippets.
kevinmoran /BitTwiddling.h
CreatedFebruary 1, 2023 12:31
Bit Twiddling Tricks From Game Engine Gems 2 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // https://twitter.com/EricLengyel/status/1620683606216835073 | |
| intclearLowestSetBit(intx) | |
| { | |
| returnx& (x-1); | |
| } | |
| intsetLowestUnsetBit(intx) | |
| { | |
| returnx | (x+1); |
kevinmoran /SquirrelNoise5.hpp
CreatedJuly 22, 2022 22:45
Improvement on Squirrel3 noise-based RNG by Squirrel Eiserloh (https://twitter.com/SquirrelTweets/status/1421251894274625536) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| //----------------------------------------------------------------------------------------------- | |
| // SquirrelNoise5.hpp | |
| // | |
| #pragma once | |
| ///////////////////////////////////////////////////////////////////////////////////////////////// | |
| // SquirrelNoise5 - Squirrel's Raw Noise utilities (version 5) | |
| // | |
| // This code is made available under the Creative Commons attribution 3.0 license (CC-BY-3.0 US): |
kevinmoran /MikeActonArticlesAndTalks.md
Last activeJune 12, 2025 21:54
Collection of great articles and talks by Mike Acton- It Doesn't Have To Suck
- SIEGE 2013: You're Responsible
- Technical Direction: Communication, ROI and Triage
- Solving the Right Problems for Engine Programmers (TGC 2017)
- Should your Engineering Lead be fired?
- What Specific Change Do I Want?
- Empathy - 10 Questions To Ask Myself
- Lead Quick Start Guide
- [How much time should I spend coding versus managing?](https://itsyourturnblog.com/how-much-time-should-i-spend-coding-versus-managing-4f8e5c4551c6
kevinmoran /rand_float.cpp
CreatedMarch 31, 2021 15:49
Converting an integer to a float between 0 and 1 with bithacks (for PRNG) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // Source: "xoshiro / xoroshiro generators and the PRNG shootout" | |
| // https://prng.di.unimi.it/ | |
| #include<stdint.h> | |
| staticinlinedoubleu64ToDoubleBetween01(uint64_t x) { | |
| return (x >>11) *0x1.0p-53; | |
| } | |
| // I came up with the following function for 32-bit floats based on the above, let me know if it's wrong |
kevinmoran /EntityProperties.cpp
CreatedJanuary 21, 2021 23:11
Stretchy bitflags - Nifty code snippet from Ryan Fleury shared on Handmade Network discord This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| enum EntityProperty | |
| { | |
| EntityProperty_IsActive, | |
| EntityProperty_RenderModel, | |
| EntityProperty_Hostile, | |
| EntityProperty_OnFire, | |
| EntityProperty_SomethingElse, | |
| EntityProperty_Count | |
| }; |
- encoding:http://www.unicode.org/versions/Unicode13.0.0/
- shaping:https://harfbuzz.github.io/
- font file format:https://docs.microsoft.com/en-us/typography/opentype/spec/
- rasterization:
- https://nothings.org/gamedev/rasterize/
- http://rastertragedy.com/
- https://www.grc.com/cleartype.htm
- https://www.freetype.org/freetype2/docs/text-rendering-general.html
- Rendering Resolution Independent Fonts in Games and 3D Applications (Master's Thesis - Olle Alvin):https://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=9024910&fileOId=9024911
- Adventures in Text Rendering: Kerning and Glyph Atlases:https://www.warp.dev/blog/adventures-text-rendering-kerning-glyph-atlases
kevinmoran /Programming Wisdom.md
Last activeMay 20, 2024 11:45
List of useful programming resources I've found- The Perils of Future-Coding - Sebastian Sylvan
- John Carmack on Inlined Code
- CppCon 2014: Mike Acton "Data-Oriented Design and C++"
- Semantic Compression - Casey Muratori
- Learning From Failure - Alex Evans. Talk about the long development of Media Molecule's Dreams.
- Thirteen Years of Bad Game Code - Evan Todd
- Memory Allocation Strategies blog series
- The Mundanity of Excellence - Daniel F. Chambliss. Really accessible academic paper on how people achieve excellence, literally everyone on earth should read this.
- [Mike
kevinmoran /Murmur3.cpp
CreatedMay 27, 2020 09:26
Simple MurmurHash3 Implementation (from Demetri Spanos) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // Minimal Murmur3 implementation shared by Demetri Spanos on Handmade Network Discord | |
| // | |
| // Code is deliberately terse and simplistic | |
| // Intended to be the first hash function you reach for e.g. a simple hash table | |
| // *** NB THIS IS NOT A CRYPTOGRAPHIC HASH *** | |
| // | |
| // @demetrispanos: | |
| // "yes let me reiterate the moral of this story | |
| // there is never any reason to use a dumb made up hash function | |
| // use murmur3 or jenkins-one-at-a-time for a 0-effort version |
kevinmoran /WASAPI Play .wav File.cpp
Last activeApril 29, 2025 05:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| // Simple example code to load a Wav file and play it with WASAPI | |
| // This is NOT complete Wav loading code. It is a barebones example | |
| // that makes a lot of assumptions, see the assert() calls for details | |
| // | |
| // References: | |
| // http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html | |
| // Handmade Hero Day 138: Loading WAV Files | |
| #include<windows.h> |
kevinmoran /WASAPI Render Sine Wave.cpp
Last activeJanuary 29, 2025 19:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| #include<windows.h> | |
| #include<mmdeviceapi.h> | |
| #include<audioclient.h> | |
| #include<assert.h> | |
| #define_USE_MATH_DEFINES | |
| #include<math.h>// for sin() | |
| #include<stdint.h> |
NewerOlder