4 #pragma comment (lib, "d3d11.lib")
6 HINSTANCE g_hInst = NULL;
7 D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL;
8 D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0;
9 ID3D11Device* g_pd3dDevice = NULL;
10 ID3D11DeviceContext* g_pImmediateContext = NULL;
11 IDXGISwapChain* g_pSwapChain = NULL;
13 static HRESULT InitDevice()
20 UINT createDeviceFlags = 0;
22 D3D_DRIVER_TYPE driverTypes[] =
24 D3D_DRIVER_TYPE_HARDWARE,
26 D3D_DRIVER_TYPE_REFERENCE,
28 UINT numDriverTypes = ARRAYSIZE(driverTypes);
30 D3D_FEATURE_LEVEL featureLevels[] =
32 D3D_FEATURE_LEVEL_11_0,
33 D3D_FEATURE_LEVEL_10_1,
34 D3D_FEATURE_LEVEL_10_0,
36 UINT numFeatureLevels = ARRAYSIZE(featureLevels);
38 DXGI_SWAP_CHAIN_DESC sd;
39 ZeroMemory( &sd, sizeof( sd ) );
41 sd.BufferDesc.Width = width;
42 sd.BufferDesc.Height = height;
43 sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
44 sd.BufferDesc.RefreshRate.Numerator = 60;
45 sd.BufferDesc.RefreshRate.Denominator = 1;
46 sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
47 sd.OutputWindow = NULL; //g_hWnd;
48 sd.SampleDesc.Count = 1;
49 sd.SampleDesc.Quality = 0;
52 for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
54 g_driverType = driverTypes[driverTypeIndex];
55 hr = D3D11CreateDeviceAndSwapChain(NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,
56 D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext);
66 int main(int /*argc*/, char** /*argv*/)