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
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. |
#define WIN32_LEAN_AND_MEAN | |
#include <winsock2.h> | |
#include <windows.h> | |
#define SECURITY_WIN32 | |
#include <security.h> | |
#include <schannel.h> | |
#include <shlwapi.h> | |
#include <assert.h> | |
#include <stdio.h> |
Minimal WASAPI reference implementation. Runnable console application contained in a single function and laid out in a linear, step-by-step fashion. No modern C++ / OOP / obscuring cruft. Produces a steady sine wave sound.
(This is a re-post of the same gist I posted a few years earlier, simply due to me wanting the Minimal D3D11 series to be listed contiguously and it's not possible to hide or rearrange gists).
from typing import Optional, Tuple, Union, overload | |
_time_unit_map = { | |
"ps": -12, | |
"ns": -9, | |
"us": -6, | |
"ms": -3, | |
"s": 0, | |
} |
#include <stdint.h> | |
typedef struct { | |
char function[256]; //mangled or unmangled function name | |
char module[256]; //mangled or unmangled module name ie. name of dll/executable | |
char file[256]; //file or empty if not supported | |
int64_t line; //0 if not supported | |
} Platform_Stack_Trace_Entry; | |
//Captures the current stack frame pointers. | |
//Saves up to stack_size pointres into the stack array and returns the number of |
Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes anchor/pivot point, rotation, 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.
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
//////////////////////////////// | |
// NBHS - Non-blocking hashset | |
//////////////////////////////// | |
// You wanna intern lots of things on lots of cores? this is for you. It's | |
// inspired by Cliff's non-blocking hashmap. | |
// | |
// To use it, you'll need to define NBHS_FN and then include the header: | |
// | |
// #define NBHS_FN(n) XXX_hs_ ## n | |
// #include <nbhs.h> |
#include "friday.h" | |
Entry(InputWaveInfo) | |
{ | |
wave_info *WaveInfo = (wave_info*)InputWaveInfo; | |
shared_wave_info *Shared = WaveInfo->Shared; | |
memory_arena Arena = {0}; | |
Arena.Start = MemoryReserve(GigaBytes(64)); |
//Combination of the following: | |
// original gist: https://gist.github.com/pmttavara/6f06fc5c7679c07375483b06bb77430c | |
// discussion here: https://hero.handmade.network/forums/code-discussion/t/7485-queryperformancefrequency_returning_10mhz_bug/2#23567 | |
// dump_vdso_data.c: https://gist.github.com/mildsunrise/c63505931534bd3c0e143c0db8cad3f3 | |
// | |
// Original license: | |
// SPDX-FileCopyrightText: © 2022 Phillip Trudeau-Tavara <[email protected]> | |
// SPDX-License-Identifier: 0BSD | |
// https://linux.die.net/man/2/perf_event_open |