X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;ds=sidebyside;f=apps%2Fd3d10_1%2Ftri.cpp;h=7f128bcd0627adc7d75b2fedcf6302f3d4bbb689;hb=29bc86c9885156cfb998ae3aa42ddb026c300398;hp=4aed3508ad693edc8cee319efc3a28a13b8fefc3;hpb=660ae172b47404abb185e2ab74deac02cda7260e;p=apitrace-tests diff --git a/apps/d3d10_1/tri.cpp b/apps/d3d10_1/tri.cpp index 4aed350..7f128bc 100644 --- a/apps/d3d10_1/tri.cpp +++ b/apps/d3d10_1/tri.cpp @@ -38,11 +38,15 @@ #include "tri_ps_4_0.h" +static IDXGIFactory1 *g_pFactory = NULL; +static IDXGIAdapter *g_pAdapter = NULL; static IDXGISwapChain* g_pSwapChain = NULL; static ID3D10Device1 * g_pDevice = NULL; -int main(int argc, char *argv[]){ +int +main(int argc, char *argv[]) +{ HRESULT hr; HINSTANCE hInstance = GetModuleHandle(NULL); @@ -93,10 +97,29 @@ int main(int argc, char *argv[]){ Flags |= D3D10_CREATE_DEVICE_DEBUG; } + hr = CreateDXGIFactory1(IID_IDXGIFactory1, (void**)(&g_pFactory) ); + if (FAILED(hr)) { + return 1; + } + + hr = g_pFactory->EnumAdapters(0, &g_pAdapter); + if (FAILED(hr)) { + return 1; + } + + hr = D3D10CreateDevice1(g_pAdapter, + D3D10_DRIVER_TYPE_HARDWARE, + NULL, + Flags, + D3D10_FEATURE_LEVEL_10_0, + D3D10_1_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,16 +129,9 @@ int main(int argc, char *argv[]){ SwapChainDesc.BufferCount = 2; SwapChainDesc.OutputWindow = hWnd; SwapChainDesc.Windowed = true; + SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - hr = D3D10CreateDeviceAndSwapChain1(NULL, - D3D10_DRIVER_TYPE_HARDWARE, - NULL, - Flags, - D3D10_FEATURE_LEVEL_10_0, - D3D10_1_SDK_VERSION, - &SwapChainDesc, - &g_pSwapChain, - &g_pDevice); + hr = g_pFactory->CreateSwapChain(g_pDevice, &SwapChainDesc, &g_pSwapChain); if (FAILED(hr)) { return 1; }