+ UINT Flags = 0;
+ if (LoadLibraryA("d3d10sdklayers")) {
+ 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;
+ }
+