| ↓ on → | CPU | OpenGL | OpenGLES | D3D9 | D3D11 | D3D12 | Vulkan | Metal |
|---|---|---|---|---|---|---|---|---|
| OpenGL | [llvmpipe][] | - | [gl4es][] | [TitaniumGL][] | [d3d12][] | [zink][] | ||
| OpenGLES | [llvmpipe][] [SwiftShader][slegacy] | [ANGLE][] | - | [ANGLE][] | [ANGLE][] | [d3d12][] [ANGLE][] | [zink][] [ANGLE][] | [ANGLE][] [MoltenGL][] |
| D3D9 | [SwiftShader][slegacy] | [wined3d][] | - | [D3D9on12][] | [DXVK][] | |||
| D3D11 | [WARP][] | [wined3d][] |
| /* | |
| * Creator: Naman Dixit | |
| * Notice: © Copyright 2024 Naman Dixit | |
| * License: BSD Zero Clause License | |
| * SPDX: 0BSD (https://spdx.org/licenses/0BSD.html) | |
| */ | |
| /* | |
| * This is an single-header zero-dependency easily-embeddable C23 parser and associated pretty-printer. | |
| * |
| /* | |
| * Creator: Naman Dixit | |
| * Notice: © Copyright 2024 Naman Dixit | |
| * License: BSD Zero Clause License | |
| * SPDX: 0BSD (https://spdx.org/licenses/0BSD.html) | |
| */ | |
| #if !defined(STD_H_INCLUDE_GUARD) | |
| /* Compiler **************************************************************************/ |
Example of how to capture CPU counters with ETW on Windows, perf on Linux or kperf on Apple.
Using ETW needs somewhat recently updated Windows 10 or 11. Not sure about exact version.
Currently tested on:
- etw on Qualcomm Snapdragon X Elite, Windows 11, arm64
- etw on AMD Zen 3, Windows 11 (with virtualization enabled in BIOS)
| #include <stdint.h> | |
| #include <stdlib.h> | |
| #include <stdbool.h> | |
| #include <windows.h> | |
| #pragma comment( lib, "user32.lib" ) | |
| #pragma comment( lib, "gdi32.lib" ) | |
| #define SCRW 640 | |
| #define SCRH 480 |
| Complete stuff: | |
| https://xmonader.github.io/letsbuildacompiler-pretty/ | |
| Lexers + DFAs: | |
| https://gist.github.com/pervognsen/218ea17743e1442e59bb60d29b1aa725 | |
| Parsing: | |
| https://eli.thegreenplace.net/2012/08/02/parsing-expressions-by-precedence-climbing | |
| Backend: |
| // example how to set up WebGPU rendering on Windows in C | |
| // uses Dawn implementation of WebGPU: https://dawn.googlesource.com/dawn/ | |
| // download pre-built Dawn webgpu.h/dll/lib files from https://github.com/mmozeiko/build-dawn/releases/latest | |
| #include "webgpu.h" | |
| #define _CRT_SECURE_NO_DEPRECATE | |
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> |
A minimal Direct3D 11 implementation of "antialiased point sampling", useful for smooth fractional movement and non-integer scaling of pixel art AKA "fat pixel" aesthetics.
Also view below side-by-side point sampling comparison on YouTube (video is zoomed in to counter implicit downsampling & compression artifacts and make aa effect more apparent) or check out the original Shadertoy.
The actual sampler is set to bilinear filtering (the default D3D11 sampler state) in order to utilize single texture-read hardware interpolation, then emulating point sampling in the shader and applying AA at the fat pixel boundaries. Use with premultiplied alpha textures* and keep a one pixel transparent border around
This downloads standalone MSVC compiler, linker & other tools, also headers/libraries from Windows SDK into portable folder, without installing Visual Studio. Has bare minimum components - no UWP/Store/WindowsRT stuff, just files & tools for native desktop app development.
Run py.exe portable-msvc.py and it will download output into msvc folder. By default it will download latest available MSVC & Windows SDK from newest Visual Studio.
You can list available versions with py.exe portable-msvc.py --show-versions and then pass versions you want with --msvc-version and --sdk-version arguments.
To use cl.exe/link.exe first run setup_TARGET.bat - after that PATH/INCLUDE/LIB env variables will be updated to use all the tools as usual. You can also use clang-cl.exe with these includes & libraries.
To use clang-cl.exe without running setup.bat, pass extra /winsysroot msvc argument (msvc is folder name where output is stored).
| // example how to set up OpenGL core context on Windows | |
| // and use basic functionality of OpenGL 4.5 version | |
| // important extension functionality used here: | |
| // (4.3) KHR_debug: https://www.khronos.org/registry/OpenGL/extensions/KHR/KHR_debug.txt | |
| // (4.5) ARB_direct_state_access: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_direct_state_access.txt | |
| // (4.1) ARB_separate_shader_objects: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_separate_shader_objects.txt | |
| // (4.2) ARB_shading_language_420pack: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shading_language_420pack.txt | |
| // (4.3) ARB_explicit_uniform_location: https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_explicit_uniform_location.txt |
