36 pDevice(nullptr), pSwapChain(nullptr)
38 const auto hModDXGI = GetModuleHandle(
"DXGI.dll");
39 const auto hModD3D10 = GetModuleHandle(
"D3D10.dll");
41 if (hModDXGI ==
nullptr)
46 if (hModD3D10 ==
nullptr)
51 const auto hCreateDXGIFactory =
static_cast<LPVOID
>(GetProcAddress(hModDXGI,
"CreateDXGIFactory"));
52 if (hCreateDXGIFactory ==
nullptr)
57 ComPtr<IDXGIFactory> pFactory;
58 const auto hr =
static_cast<HRESULT(WINAPI *)(
60 void** ppFactory)
>(hCreateDXGIFactory)(
61 __uuidof(IDXGIFactory),
62 reinterpret_cast<void**
>(pFactory.GetAddressOf()));
69 const auto hD3D10CreateDeviceAndSwapChain =
static_cast<LPVOID
>(GetProcAddress(
71 "D3D10CreateDeviceAndSwapChain"));
72 if (hD3D10CreateDeviceAndSwapChain ==
nullptr)
78 ComPtr<IDXGIAdapter> pAdapter;
79 std::vector<ComPtr<IDXGIAdapter>> vAdapters;
80 while (pFactory->EnumAdapters(i, pAdapter.ReleaseAndGetAddressOf()) != DXGI_ERROR_NOT_FOUND)
82 vAdapters.push_back(pAdapter);
86 if (vAdapters.empty())
88 throw RuntimeException(
"No adapters found");
91 temp_window = std::make_unique<Window>(
"TempDirect3D10OverlayWindow");
93 DXGI_RATIONAL rational = {};
94 rational.Numerator = 60;
95 rational.Denominator = 1;
97 DXGI_MODE_DESC modeDesc = {};
98 modeDesc.Height = 100;
100 modeDesc.RefreshRate = rational;
101 modeDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
103 DXGI_SAMPLE_DESC sampleDesc = {};
104 sampleDesc.Count = 1;
105 sampleDesc.Quality = 0;
107 DXGI_SWAP_CHAIN_DESC scDesc = {};
108 scDesc.BufferCount = 1;
110 scDesc.Windowed =
true;
112 scDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
113 scDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
114 scDesc.SampleDesc = sampleDesc;
115 scDesc.BufferDesc = modeDesc;
117 const auto hr10 =
static_cast<HRESULT(WINAPI *)(
123 DXGI_SWAP_CHAIN_DESC*,
125 ID3D10Device**)
>(hD3D10CreateDeviceAndSwapChain)(
127 D3D10_DRIVER_TYPE_HARDWARE,