Skip to content

Instantly share code, notes, and snippets.

@d7samurai
d7samurai / .readme.md
Last active July 14, 2024 10:17
Minimal D3D11 sprite renderer NEO

sponsored by SuperNeo copy 4

Minimal D3D11 sprite renderer NEO

Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes rotation, anchor/pivot point, color filtering, alpha blending and built-in antialiased point sampling. As usual: complete, runnable single-function app. ~150 LOC. No modern C++, OOP or (other) obscuring cruft.

Minimal D3D11 sprite renderer NEO 1337

Sprites are rendered back-to-front (AKA "painter's algorithm") in the order they are submitted, as one draw call. The provided setup employs a single texture atlas containing all the sprite graphics.

The renderer is "im

@d7samurai
d7samurai / .readme.md
Last active July 14, 2024 04:23
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;
@ibireme
ibireme / kpc_demo.c
Last active July 16, 2024 10:53
A demo shows how to read Intel or Apple M1 CPU performance counter in macOS.
// =============================================================================
// XNU kperf/kpc demo
// Available for 64-bit Intel/Apple Silicon, macOS/iOS, with root privileges
//
//
// Demo 1 (profile a function in current thread):
// 1. Open directory '/usr/share/kpep/', find your CPU PMC database.
// M1 (Pro/Max/Ultra): /usr/share/kpep/a14.plist
// M2 (Pro/Max): /usr/share/kpep/a15.plist
// M3: /usr/share/kpep/as1.plist
@mmozeiko
mmozeiko / pcg32.h
Last active February 5, 2024 10:46
simple standalone C headers for PCG random number generator
#pragma once
#include <stdint.h>
#define PCG_DEFAULT_MULTIPLIER_64 6364136223846793005ULL
#define PCG_DEFAULT_INCREMENT_64 1442695040888963407ULL
typedef struct {
uint64_t state;
} pcg32;
@nicebyte
nicebyte / dyn_arr.h
Last active July 1, 2024 10:44
dyn_arr
#pragma once
#define DYN_ARR_OF(type) struct { \
type *data; \
type *endptr; \
uint32_t capacity; \
}
#if !defined(__cplusplus)
#define decltype(x) void*
@paniq
paniq / ellipsoid_frustum.md
Last active December 30, 2021 20:13
Ellipsoid Frustum Intersection

Ellipsoid Frustum Intersection

Yesterday I posted a problem to math stack exchange that bothered me for a while now, and right after I've had a few exchanges on Twitter, I got inspired to attempt a solution.

Here it goes. It's 100% untested but I'm fairly certain that it will work.

The problem is about a form of refining raytracing where we render a big list of convex 3D brushes (and I decided to start with Ellipsoids, since they're so useful) to the screen or a shadow map, without any prebuilt accelleration structure. How does it work? Well, if we had a way to figure out for a portion of the frustum whether it contained a brush, we could

  1. Start with a very low resolution
@gorlak
gorlak / tools-engineer-checklist.md
Last active July 9, 2024 15:47
Tools Engineer Checklist

This list is provided as a guide for tools engineers of all skill levels looking for jobs in the game industry. It's meant as a guide to topics that should be pursued broadly in order to be well spoken in an interview. I doubt any hiring manager requires deep knowedge across every topic, but an ideal candidate would be somewhat knowledgable (aware of its existence if asked directly) with all topics here.

Each list of bullets increases in difficulty, so later bullets are more applicable to senior (or even director) level candidates.

Good luck.

@gorlak

Math

@lqd
lqd / gist:1c841dea193698bf50fefa19c6b3fb99
Last active December 10, 2023 19:17
Some of my favorite development streams and shows
Why coding streams/shows are interesting to me: in some livestreams, the experience is very similar to pair programming,
but those people are experts. In VODs, it's more about problem solving and learning skills and approaches. The devs are really good
at what they do and there is *always* a lot to learn.
In no particular order:
1) Handmade Hero
About the author: Casey Muratori. Worked at RAD.
Description and why I like it: It kinda started the whole thing for me. Casey is coding a complete game and engine on stream,
from scratch, one hour a day. He knows what he's doing on so many of the domains of game development and regular programing,
@mlfarrell
mlfarrell / membuf.cpp
Created May 28, 2016 01:11
C++ streams from memory buffer
struct membuf : std::streambuf
{
membuf(char *begin, char *end) : begin(begin), end(end)
{
this->setg(begin, begin, end);
}
virtual pos_type seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which = std::ios_base::in) override
{
if(dir == std::ios_base::cur)