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;
44
sd.BufferDesc.Format = DXGI_FORMAT_NV12;
46
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
48
sd.BufferDesc.RefreshRate.Numerator = 60;
49
sd.BufferDesc.RefreshRate.Denominator = 1;
50
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
51
sd.OutputWindow = NULL; //g_hWnd;
52
sd.SampleDesc.Count = 1;
53
sd.SampleDesc.Quality = 0;
56
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++)
58
g_driverType = driverTypes[driverTypeIndex];
59
hr = D3D11CreateDeviceAndSwapChain(NULL, g_driverType, NULL, createDeviceFlags, featureLevels, numFeatureLevels,
60
D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext);
70
int main(int /*argc*/, char** /*argv*/)