This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 996
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-implemented Kiero but stripped down for just what we need (#79)
- Loading branch information
1 parent
92f9a91
commit 437ebbc
Showing
7 changed files
with
140 additions
and
67 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include "directx11.h" | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <Windows.h> | ||
|
||
directx11::directx11() | ||
{ | ||
WNDCLASSEX windowClass = { | ||
sizeof(WNDCLASSEX), | ||
CS_HREDRAW | CS_VREDRAW, | ||
DefWindowProc, | ||
0, | ||
0, | ||
GetModuleHandle(NULL), | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
L"DirectX 11", | ||
NULL, | ||
}; | ||
|
||
RegisterClassEx(&windowClass); | ||
HWND window = CreateWindow(windowClass.lpszClassName, L"DirectX 11 Window", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, NULL, windowClass.hInstance, NULL); | ||
|
||
D3D_FEATURE_LEVEL featureLevel; | ||
const D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_11_0 }; | ||
|
||
DXGI_MODE_DESC bufferDesc = { | ||
100, | ||
100, | ||
{60, 1}, | ||
DXGI_FORMAT_R8G8B8A8_UNORM, | ||
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED, | ||
DXGI_MODE_SCALING_UNSPECIFIED, | ||
}; | ||
|
||
DXGI_SWAP_CHAIN_DESC swapChainDesc = { | ||
bufferDesc, | ||
{1, 0}, | ||
DXGI_USAGE_RENDER_TARGET_OUTPUT, | ||
1, | ||
window, | ||
1, | ||
DXGI_SWAP_EFFECT_DISCARD, | ||
DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH, | ||
}; | ||
|
||
IDXGISwapChain* pSwapChain; | ||
ID3D11Device* pDevice; | ||
ID3D11DeviceContext* pContext; | ||
|
||
HRESULT result = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, featureLevels, 2, D3D11_SDK_VERSION, &swapChainDesc, &pSwapChain, &pDevice, &featureLevel, &pContext); | ||
|
||
if (FAILED(result)) { | ||
DestroyWindow(window); | ||
UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); | ||
return; | ||
} | ||
|
||
void** pVMT = *(void***)pSwapChain; | ||
presentFunction = (D3D_PRESENT_FUNCTION)pVMT[8]; | ||
|
||
if (pSwapChain) { | ||
pSwapChain->Release(); | ||
pSwapChain = NULL; | ||
} | ||
|
||
if (pDevice) { | ||
pDevice->Release(); | ||
pDevice = NULL; | ||
} | ||
|
||
if (pContext) { | ||
pContext->Release(); | ||
pContext = NULL; | ||
} | ||
|
||
DestroyWindow(window); | ||
UnregisterClass(windowClass.lpszClassName, windowClass.hInstance); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
#include <dxgi.h> | ||
#include <d3d11.h> | ||
|
||
typedef HRESULT(__stdcall* D3D_PRESENT_FUNCTION)(IDXGISwapChain* __this, UINT SyncInterval, UINT Flags); | ||
|
||
class directx11 { | ||
public: | ||
D3D_PRESENT_FUNCTION presentFunction; | ||
directx11(); | ||
}; |