Last active
December 9, 2017 18:20
-
-
Save kayru/7573409 to your computer and use it in GitHub Desktop.
This file contains 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
// cl /nologo /I "%DXSDK_DIR%\Include" rastafontgpu.cpp /link /LIBPATH:"%DXSDK_DIR%\Lib\x86" | |
#include <tchar.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <windows.h> | |
#include <D3D11.h> | |
#pragma comment(lib, "kernel32.lib") | |
#pragma comment(lib, "gdi32.lib") | |
#pragma comment(lib, "user32.lib") | |
#pragma comment(lib, "d3d11.lib") | |
static const uint32_t WindowWidth = 1280; | |
static const uint32_t WindowHeight = 720; | |
static const char* WindowName = "Rastafont GPU"; | |
#define CHECKHR(hr) {if(FAILED(hr)){printf("D3D Error at line %d: 0x%08X\n", __LINE__,(int)hr); DebugBreak();}} | |
// https://gist.github.com/kayru/7573287 | |
const unsigned char g_rastaforn8x8_cs[] = { | |
0x44,0x58,0x42,0x43,0x6D,0x33,0x91,0xEC,0x26,0x3D,0x44,0x71,0x0E,0x0C,0x9E,0xCC, | |
0xC7,0x56,0xFF,0xA1,0x01,0x00,0x00,0x00,0x50,0x0F,0x00,0x00,0x05,0x00,0x00,0x00, | |
0x34,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x08,0x01,0x00,0x00,0x18,0x01,0x00,0x00, | |
0xB4,0x0E,0x00,0x00,0x52,0x44,0x45,0x46,0xBC,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x00,0x05,0x53,0x43, | |
0x00,0x01,0x00,0x00,0x89,0x00,0x00,0x00,0x52,0x44,0x31,0x31,0x3C,0x00,0x00,0x00, | |
0x18,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x24,0x00,0x00,0x00, | |
0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x02,0x00,0x00,0x00, | |
0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, | |
0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x82,0x00,0x00,0x00,0x04,0x00,0x00,0x00, | |
0x05,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00, | |
0x01,0x00,0x00,0x00,0x0D,0x00,0x00,0x00,0x69,0x6E,0x70,0x75,0x74,0x00,0x6F,0x75, | |
0x74,0x70,0x75,0x74,0x00,0x4D,0x69,0x63,0x72,0x6F,0x73,0x6F,0x66,0x74,0x20,0x28, | |
0x52,0x29,0x20,0x48,0x4C,0x53,0x4C,0x20,0x53,0x68,0x61,0x64,0x65,0x72,0x20,0x43, | |
0x6F,0x6D,0x70,0x69,0x6C,0x65,0x72,0x20,0x39,0x2E,0x32,0x39,0x2E,0x39,0x35,0x32, | |
0x2E,0x33,0x31,0x31,0x31,0x00,0xAB,0xAB,0x49,0x53,0x47,0x4E,0x08,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x4F,0x53,0x47,0x4E,0x08,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x53,0x48,0x45,0x58,0x94,0x0D,0x00,0x00, | |
0x50,0x00,0x05,0x00,0x65,0x03,0x00,0x00,0x6A,0x08,0x00,0x01,0x35,0x18,0x00,0x00, | |
0xFA,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x1E,0x1E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x36,0x36,0x7F,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7F,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x3E,0x03,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x30,0x1F,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x63,0x33,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x66,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1C,0x36,0x1C,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3B,0x33,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x0C,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x66,0x3C,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x3B,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x37,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0F,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x30,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x33,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x30,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x30,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x38,0x3C,0x36,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7F,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x03,0x1F,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x30,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1C,0x06,0x03,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x33,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x33,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x30,0x18,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x0E,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x0C,0x06,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3E,0x63,0x7B,0x7B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7B,0x03,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x1E,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x66,0x66,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3C,0x66,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x03,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x36,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x66,0x36,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7F,0x46,0x16,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x16,0x46,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7F,0x46,0x16,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x16,0x06,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3C,0x66,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x73,0x66,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x78,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x67,0x66,0x36,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x36,0x66,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0F,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x46,0x66,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x63,0x77,0x7F,0x6B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x63,0x67,0x6F,0x7B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x73,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1C,0x36,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x63,0x36,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x06,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3B,0x1E,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x66,0x66,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x36,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x33,0x07,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x38,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x2D,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x1E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x6B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7F,0x77,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x63,0x63,0x36,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x36,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x7F,0x33,0x19,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x46,0x63,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x06,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x06,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x03,0x06,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x30,0x60,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x18,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3E,0x33,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x07,0x06,0x3E,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x66,0x66,0x3D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x03,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x38,0x30,0x30,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x3F,0x03,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1C,0x36,0x06,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x06,0x06,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x3E,0x30,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x07,0x06,0x36,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x66,0x66,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x00,0x0E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x00,0x1E,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x18,0x1B,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x07,0x06,0x66,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x36,0x67,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0E,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x37,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x6B,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x66,0x3E,0x06,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x3E,0x30,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x36,0x06,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1E,0x30,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x08,0x0C,0x3E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x2C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x33,0x6E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x1E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x6B,0x7F,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x1C,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x33,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x33,0x3E,0x30,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x26,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x38,0x0C,0x0C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x07,0x0C,0x0C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x0C,0x0C,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x6E,0x3B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x58,0x18,0x00,0x04,0x00,0x70,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x44,0x44,0x00,0x00,0x9C,0x18,0x00,0x04,0x00,0xE0,0x11,0x00,0x00,0x00,0x00,0x00, | |
0x55,0x55,0x00,0x00,0x5F,0x00,0x00,0x02,0x32,0x10,0x02,0x00,0x5F,0x00,0x00,0x02, | |
0x32,0x20,0x02,0x00,0x5F,0x00,0x00,0x02,0x32,0x00,0x02,0x00,0x68,0x00,0x00,0x02, | |
0x01,0x00,0x00,0x00,0x9B,0x00,0x00,0x04,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00, | |
0x01,0x00,0x00,0x00,0x36,0x00,0x00,0x04,0x32,0x00,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x46,0x10,0x02,0x00,0x36,0x00,0x00,0x08,0xC2,0x00,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x02,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x2D,0x00,0x00,0x89,0xC2,0x00,0x00,0x80,0x03,0x11,0x11,0x00, | |
0x12,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x46,0x0E,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x46,0x7E,0x10,0x00,0x00,0x00,0x00,0x00,0x29,0x00,0x00,0x07,0x12,0x00,0x10,0x00, | |
0x00,0x00,0x00,0x00,0x0A,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x00, | |
0x01,0x00,0x00,0x00,0x1E,0x00,0x00,0x07,0x12,0x00,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x0A,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x00,0xC0,0xFF,0xFF,0xFF, | |
0x55,0x00,0x00,0x06,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x1A,0x20,0x02,0x00, | |
0x01,0x40,0x00,0x00,0x02,0x00,0x00,0x00,0x1E,0x00,0x00,0x07,0x12,0x00,0x10,0x00, | |
0x00,0x00,0x00,0x00,0x1A,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,0x10,0x00, | |
0x00,0x00,0x00,0x00,0x23,0x00,0x00,0x07,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x1A,0x20,0x02,0x00,0x01,0x40,0x00,0x00,0x08,0x00,0x00,0x00,0x0A,0x20,0x02,0x00, | |
0x29,0x00,0x00,0x07,0x22,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x40,0x00,0x00, | |
0x01,0x00,0x00,0x00,0x1A,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x08, | |
0x12,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x1A,0x00,0x10,0x00,0x00,0x00,0x00,0x00, | |
0x0A,0x90,0x90,0x00,0x0A,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x04,0x03, | |
0x0A,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xA4,0x00,0x00,0x09,0xF2,0xE0,0x11,0x00, | |
0x00,0x00,0x00,0x00,0x46,0x05,0x02,0x00,0x02,0x40,0x00,0x00,0x00,0x00,0x80,0x3F, | |
0x00,0x00,0x80,0x3F,0x00,0x00,0x80,0x3F,0x00,0x00,0x80,0x3F,0x15,0x00,0x00,0x01, | |
0x3E,0x00,0x00,0x01,0x53,0x54,0x41,0x54,0x94,0x00,0x00,0x00,0x0E,0x00,0x00,0x00, | |
0x01,0x00,0x00,0x00,0xBE,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x04,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 | |
}; | |
struct Context | |
{ | |
HWND hwnd; | |
bool finished; | |
ID3D11Device* device; | |
ID3D11DeviceContext* device_context; | |
IDXGISwapChain* swap_chain; | |
ID3D11Texture2D* backbuffer_tex; | |
ID3D11RenderTargetView* backbuffer_rtv; | |
ID3D11UnorderedAccessView* backbuffer_uav; | |
ID3D11Texture2D* text_tex; | |
ID3D11ShaderResourceView* text_srv; | |
ID3D11ComputeShader* font_cs; | |
}; | |
template <typename T> | |
inline void safe_release(T& x) | |
{ | |
if(x) | |
{ | |
x->Release(); | |
x=NULL; | |
} | |
} | |
LRESULT APIENTRY WndProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) | |
{ | |
Context* ctx = reinterpret_cast<Context*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); | |
switch(msg) | |
{ | |
case WM_CLOSE: | |
ctx->finished = true; | |
default: | |
return (LONG)DefWindowProc(hwnd, msg, wparam, lparam); | |
} | |
} | |
Context* Init() | |
{ | |
Context* ctx = new Context; | |
ZeroMemory(ctx, sizeof(*ctx)); | |
ctx->finished = false; | |
// register window class | |
WNDCLASSEX wc = {0}; | |
HINSTANCE hInst = GetModuleHandle(NULL); | |
wc.cbSize = sizeof(WNDCLASSEX); | |
wc.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW |CS_VREDRAW; | |
wc.lpfnWndProc = WndProc; | |
wc.cbClsExtra = 0; | |
wc.cbWndExtra = 0; | |
wc.hInstance = hInst; | |
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); | |
wc.hCursor = LoadCursor (NULL, IDC_ARROW); | |
wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); | |
wc.lpszMenuName = NULL; | |
wc.lpszClassName = _T("BoilerplateWindowClass"); | |
wc.hIconSm = wc.hIcon; | |
RegisterClassEx(&wc); | |
uint32_t window_style = WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; | |
// find screen center and create our window there | |
int32_t pos_x = GetSystemMetrics(SM_CXSCREEN) / 2 - WindowWidth/2; | |
int32_t pos_y = GetSystemMetrics(SM_CYSCREEN) / 2 - WindowHeight/2; | |
// calculate window size for required client area | |
RECT client_rect = { pos_x, pos_y, pos_x+WindowWidth, pos_y+WindowHeight}; | |
AdjustWindowRect(&client_rect, window_style, FALSE); | |
// create window | |
ctx->hwnd = CreateWindowA("BoilerplateWindowClass", WindowName, window_style, | |
client_rect.left, client_rect.top, | |
client_rect.right-client_rect.left, client_rect.bottom-client_rect.top, | |
NULL, NULL, hInst, NULL); | |
// setup window owner for message handling | |
SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR)ctx); | |
ShowWindow(ctx->hwnd, SW_SHOWNORMAL); | |
UpdateWindow(ctx->hwnd); | |
// Create D3D11 | |
DXGI_SWAP_CHAIN_DESC sd = {0}; | |
ZeroMemory( &sd, sizeof( sd ) ); | |
sd.BufferCount = 1; | |
sd.BufferDesc.Width = WindowWidth; | |
sd.BufferDesc.Height = WindowHeight; | |
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | |
sd.BufferDesc.RefreshRate.Numerator = 60; | |
sd.BufferDesc.RefreshRate.Denominator = 1; | |
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS; | |
sd.OutputWindow = ctx->hwnd; | |
sd.SampleDesc.Count = 1; | |
sd.SampleDesc.Quality = 0; | |
sd.Windowed = TRUE; | |
D3D_DRIVER_TYPE type = D3D_DRIVER_TYPE_HARDWARE; | |
IDXGIAdapter* adapter = NULL; | |
IDXGIAdapter* enumerated_adapter = NULL; | |
D3D_FEATURE_LEVEL features[] = { D3D_FEATURE_LEVEL_11_0 }; | |
const uint32_t num_features = sizeof(features) / sizeof(features[0]); | |
// Create device | |
D3D_FEATURE_LEVEL supported_features; | |
CHECKHR(D3D11CreateDeviceAndSwapChain(adapter, type, NULL, D3D11_CREATE_DEVICE_SINGLETHREADED, features, num_features, | |
D3D11_SDK_VERSION, &sd, &ctx->swap_chain, &ctx->device, | |
&supported_features, &ctx->device_context)); | |
// Get default back buffer | |
CHECKHR(ctx->swap_chain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&ctx->backbuffer_tex)); | |
CHECKHR(ctx->device->CreateRenderTargetView(ctx->backbuffer_tex, NULL, &ctx->backbuffer_rtv)); | |
D3D11_UNORDERED_ACCESS_VIEW_DESC uav; | |
uav.Format = DXGI_FORMAT_R8G8B8A8_UNORM; | |
uav.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D; | |
uav.Texture2D.MipSlice = 0; | |
CHECKHR(ctx->device->CreateUnorderedAccessView(ctx->backbuffer_tex, &uav, &ctx->backbuffer_uav)); | |
// Create compute shader | |
CHECKHR(ctx->device->CreateComputeShader(g_rastaforn8x8_cs, sizeof(g_rastaforn8x8_cs), NULL, &ctx->font_cs)); | |
// Create texture with text | |
char text[WindowWidth*WindowHeight] = {0}; | |
sprintf(text + WindowWidth*2 + 2, "the quick brown fox jumps over the lazy dog"); | |
sprintf(text + WindowWidth*4 + 2, "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG"); | |
sprintf(text + WindowWidth*6 + 2, "0 1 2 3 4 5 6 7 8 9"); | |
sprintf(text + WindowWidth*8 + 2, "! \" # $ % & ' ( ) * + , - ."); | |
sprintf(text + WindowWidth*10 + 2, ": ; < = > ? @ ^ _ ` { | } ~"); | |
D3D11_SUBRESOURCE_DATA tex_data = {0}; | |
tex_data.pSysMem = text; | |
tex_data.SysMemPitch = WindowWidth; | |
D3D11_TEXTURE2D_DESC tex = CD3D11_TEXTURE2D_DESC(DXGI_FORMAT_R8_UINT, WindowWidth, WindowHeight, 1, 1); | |
CHECKHR(ctx->device->CreateTexture2D(&tex, &tex_data, &ctx->text_tex)); | |
CHECKHR(ctx->device->CreateShaderResourceView(ctx->text_tex, NULL, &ctx->text_srv)); | |
// Set-up default Colour and Depth surfaces | |
ctx->device_context->OMSetRenderTargets(1, &ctx->backbuffer_rtv, NULL); | |
// All done, ready to rock | |
return ctx; | |
} | |
void Update(Context* ctx) | |
{ | |
const float colour_array[4] = { 0.1f, 0.2f, 0.3f, 1.0f }; | |
ctx->device_context->ClearRenderTargetView(ctx->backbuffer_rtv, colour_array); | |
ctx->device_context->CSSetShaderResources(0, 1, &ctx->text_srv); | |
ctx->device_context->CSSetUnorderedAccessViews(0, 1, &ctx->backbuffer_uav, NULL); | |
ctx->device_context->CSSetShader(ctx->font_cs, NULL, 0); | |
ctx->device_context->Dispatch(WindowWidth/8, WindowHeight/8, 1); | |
// All done, now swap | |
CHECKHR(ctx->swap_chain->Present(0, 0)); | |
} | |
void Shutdown(Context* ctx) | |
{ | |
safe_release(ctx->font_cs); | |
safe_release(ctx->backbuffer_uav); | |
safe_release(ctx->backbuffer_rtv); | |
safe_release(ctx->backbuffer_tex); | |
safe_release(ctx->text_tex); | |
safe_release(ctx->text_srv); | |
safe_release(ctx->swap_chain); | |
safe_release(ctx->device_context); | |
safe_release(ctx->device); | |
delete ctx; | |
} | |
int main() | |
{ | |
Context* ctx = Init(); | |
while(ctx->finished == false) | |
{ | |
MSG msg; | |
while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) | |
{ | |
TranslateMessage(&msg); | |
DispatchMessage(&msg); | |
} | |
Update(ctx); | |
} | |
Shutdown(ctx); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment