X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=blobdiff_plain;f=apps%2Fd3d10%2Ftri.cpp;h=1029be91906f95fe618c5735b53dde3f4f020cef;hp=08b67017edb1d5ce96f28c07912ce7c81b7b4a8a;hb=716cd83ce5cc7bd696451ff60c52d4e7443e168a;hpb=660ae172b47404abb185e2ab74deac02cda7260e diff --git a/apps/d3d10/tri.cpp b/apps/d3d10/tri.cpp index 08b6701..1029be9 100644 --- a/apps/d3d10/tri.cpp +++ b/apps/d3d10/tri.cpp @@ -38,11 +38,15 @@ #include "tri_ps_4_0.h" +static IDXGIFactory *g_pFactory = NULL; +static IDXGIAdapter *g_pAdapter = NULL; static IDXGISwapChain* g_pSwapChain = NULL; static ID3D10Device * g_pDevice = NULL; -int main(int argc, char *argv[]){ +int +main(int argc, char *argv[]) +{ HRESULT hr; HINSTANCE hInstance = GetModuleHandle(NULL); @@ -93,6 +97,26 @@ int main(int argc, char *argv[]){ Flags |= D3D10_CREATE_DEVICE_DEBUG; } + hr = CreateDXGIFactory(IID_IDXGIFactory, (void**)(&g_pFactory) ); + if (FAILED(hr)) { + return 1; + } + + hr = g_pFactory->EnumAdapters(0, &g_pAdapter); + if (FAILED(hr)) { + return 1; + } + + hr = D3D10CreateDevice(g_pAdapter, + D3D10_DRIVER_TYPE_HARDWARE, + NULL, + Flags, + D3D10_SDK_VERSION, + &g_pDevice); + if (FAILED(hr)) { + return 1; + } + DXGI_SWAP_CHAIN_DESC SwapChainDesc; ZeroMemory(&SwapChainDesc, sizeof SwapChainDesc); SwapChainDesc.BufferDesc.Width = WindowWidth; @@ -107,14 +131,7 @@ int main(int argc, char *argv[]){ SwapChainDesc.OutputWindow = hWnd; SwapChainDesc.Windowed = true; - hr = D3D10CreateDeviceAndSwapChain(NULL, - D3D10_DRIVER_TYPE_HARDWARE, - NULL, - Flags, - D3D10_SDK_VERSION, - &SwapChainDesc, - &g_pSwapChain, - &g_pDevice); + hr = g_pFactory->CreateSwapChain(g_pDevice, &SwapChainDesc, &g_pSwapChain); if (FAILED(hr)) { return 1; }