Created
October 25, 2017 02:09
-
-
Save kaneta1992/e67d3fd2cda9c0f73628fdf725bc9ec1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma comment(lib,"d3d11.lib") | |
#include <d3d11.h> | |
D3D_DRIVER_TYPE g_driverType; | |
D3D_FEATURE_LEVEL g_featureLevel; | |
ID3D11Device* g_pd3dDevice = nullptr; | |
ID3D11DeviceContext* g_pImmediateContext = nullptr; | |
HRESULT InitDevice() | |
{ | |
HRESULT hr = S_OK; | |
UINT createDeviceFlags = 0; | |
D3D_DRIVER_TYPE driverTypes[] = | |
{ | |
D3D_DRIVER_TYPE_HARDWARE, | |
D3D_DRIVER_TYPE_WARP, | |
D3D_DRIVER_TYPE_REFERENCE, | |
}; | |
UINT numDriverTypes = ARRAYSIZE(driverTypes); | |
D3D_FEATURE_LEVEL featureLevels[] = | |
{ | |
D3D_FEATURE_LEVEL_11_0, | |
}; | |
UINT numFeatureLevels = ARRAYSIZE(featureLevels); | |
for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) | |
{ | |
g_driverType = driverTypes[driverTypeIndex]; | |
hr = D3D11CreateDevice(nullptr, g_driverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, | |
D3D11_SDK_VERSION, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); | |
if (SUCCEEDED(hr)) | |
break; | |
} | |
return hr; | |
} | |
void main() | |
{ | |
InitDevice(); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment