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
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
| template <class _Ty> | |
| _NODISCARD /* constexpr */ _Ty _Common_lerp(const _Ty _ArgA, const _Ty _ArgB, const _Ty _ArgT) noexcept { | |
| // on a line intersecting {(0.0, _ArgA), (1.0, _ArgB)}, return the Y value for X == _ArgT | |
| const int _Finite_mask = (int{isfinite(_ArgA)} << 2) | (int{isfinite(_ArgB)} << 1) | int{isfinite(_ArgT)}; | |
| if (_Finite_mask == 0b111) { | |
| // 99% case, put it first; this block comes from P0811R3 | |
| if ((_ArgA <= 0 && _ArgB >= 0) || (_ArgA >= 0 && _ArgB <= 0)) { | |
| // exact, monotonic, bounded, determinate, and (for _ArgA == _ArgB == 0) consistent: | |
| return _ArgT * _ArgB + (1 - _ArgT) * _ArgA; |
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
| package freetype | |
| import "core:c" | |
| when ODIN_OS == "windows" { | |
| foreign import freetype "freetype291.lib"; | |
| } | |
| when ODIN_OS == "darwin" do foreign import freetype { | |
| "macos/libfreetype.a", | |
| } |
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 <d3d11.h> | |
| #include <iostream> | |
| #include <vector> | |
| #include <thread> | |
| #include <mutex> | |
| #include <d3dcompiler.h> | |
| #pragma comment(lib, "dxgi.lib") | |
| #pragma comment(lib, "d3d11.lib") |
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
| .PHONY: all | |
| all: rot13.wasm | |
| %.wasm.full: %.c | |
| clang $< -g -o $@ | |
| %.wasm.dwarf: %.wasm.full | |
| llvm-dwarfdump $< > $@ | |
| %.wasm: %.wasm.full %.wasm.dwarf |
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 <stdio.h> | |
| #include <SDL.h> | |
| int main(void) { | |
| SDL_Init(SDL_INIT_AUDIO); | |
| // the representation of our audio device in SDL: | |
| SDL_AudioDeviceID audio_device; | |
| // opening an audio device: |
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
| // This work (SDLblit.cpp, by Cory Bloyd) is free of known copyright restrictions. | |
| // https://creativecommons.org/publicdomain/zero/1.0/ | |
| #include <SDL.h> | |
| inline uint32_t argb(uint8_t a, uint8_t r, uint8_t g, uint8_t b) { return (a<<24) | (r << 16) | (g << 8) | (b << 0); } | |
| int main(int argc, char *argv[]) { | |
| SDL_Init(SDL_INIT_VIDEO); | |
| SDL_Rect screenRect = { 0,0,1024,1024 }; |
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
| #pragma once | |
| #if defined(_WIN32) | |
| # include <Windows.h> | |
| #elif defined(__APPLE__) || defined(LINUX) | |
| # include <sys/mman.h> | |
| #endif | |
| #include <optional> | |
| #include "result.hpp" |
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
| // | |
| // Author: Jonathan Blow | |
| // Version: 1 | |
| // Date: 31 August, 2018 | |
| // | |
| // This code is released under the MIT license, which you can find at | |
| // | |
| // https://opensource.org/licenses/MIT | |
| // | |
| // |
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
| #define WIN32_LEAN_AND_MEAN | |
| #include <windows.h> | |
| #include <dwrite.h> | |
| #include <intrin.h> | |
| #pragma comment (lib, "gdi32.lib") | |
| #pragma comment (lib, "user32.lib") | |
| #pragma comment (lib, "dwrite.lib") | |
| #define CHECK(x) do { if (!(x)) __debugbreak(); } while (0) |
