33 pd3dDevice(nullptr), pd3dDeviceContext(nullptr), pSwapChain(nullptr)
35 temp_window = std::make_unique<Window>(
"TempDirect3D11OverlayWindow");
37 const auto hModDXGI = GetModuleHandle(
"DXGI.dll");
38 const auto hModD3D11 = GetModuleHandle(
"D3D11.dll");
40 if (hModDXGI ==
nullptr)
45 if (hModD3D11 ==
nullptr)
51 DXGI_SWAP_CHAIN_DESC sd;
53 ZeroMemory(&sd,
sizeof(sd));
55 sd.BufferDesc.Width = 0;
56 sd.BufferDesc.Height = 0;
57 sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
58 sd.BufferDesc.RefreshRate.Numerator = 60;
59 sd.BufferDesc.RefreshRate.Denominator = 1;
60 sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
61 sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
63 sd.SampleDesc.Count = 1;
64 sd.SampleDesc.Quality = 0;
66 sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
69 UINT createDeviceFlags = 0;
70 D3D_FEATURE_LEVEL featureLevel;
72 const D3D_FEATURE_LEVEL featureLevelArray[] = {
73 D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0
76 const auto hD3D11CreateDeviceAndSwapChain =
static_cast<LPVOID
>(GetProcAddress(
78 "D3D11CreateDeviceAndSwapChain"
80 if (hD3D11CreateDeviceAndSwapChain ==
nullptr)
85 const auto createDevice =
static_cast<HRESULT(WINAPI *)(
90 const D3D_FEATURE_LEVEL*,
93 const DXGI_SWAP_CHAIN_DESC*,
97 ID3D11DeviceContext**)
>(hD3D11CreateDeviceAndSwapChain);
102 HRESULT hr11 = createDevice(
104 D3D_DRIVER_TYPE_HARDWARE,
108 ARRAYSIZE(featureLevelArray),
120 D3D_DRIVER_TYPE_WARP,
124 ARRAYSIZE(featureLevelArray),