X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=apps%2Fd3d10%2Ftri.cpp;h=9e0aec66c248dd3e3b0cabc70325db4c1d727447;hb=29bc86c9885156cfb998ae3aa42ddb026c300398;hp=08b67017edb1d5ce96f28c07912ce7c81b7b4a8a;hpb=660ae172b47404abb185e2ab74deac02cda7260e;p=apitrace-tests diff --git a/apps/d3d10/tri.cpp b/apps/d3d10/tri.cpp index 08b6701..9e0aec6 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,10 +97,28 @@ 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; - SwapChainDesc.BufferDesc.Height = WindowHeight; SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;; SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60; SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1; @@ -106,15 +128,9 @@ int main(int argc, char *argv[]){ SwapChainDesc.BufferCount = 2; SwapChainDesc.OutputWindow = hWnd; SwapChainDesc.Windowed = true; + SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - 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; }