@@ -6,30 +6,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
6
6
return DefWindowProc (hWnd, message, wParam, lParam);
7
7
}
8
8
9
- typedef HRESULT (__stdcall* FuncPtrD3D11CreateDeviceAndSwapChain)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType,
10
- HMODULE Software, UINT Flags, CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion,
11
- CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, IDXGISwapChain** ppSwapChain, ID3D11Device** ppDevice,
12
- D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext);
13
-
14
9
bool TestDX11Present ()
15
10
{
16
- const auto hD3D11 = XRay::LoadModule (" d3d11.dll" );
17
-
18
- if (!hD3D11->exist ())
19
- {
20
- Log (" * DX11: failed to load d3d11.dll" );
21
- return false ;
22
- }
23
-
24
- auto pD3D11CreateDeviceAndSwapChain =
25
- (FuncPtrD3D11CreateDeviceAndSwapChain)hD3D11->getProcAddress (" D3D11CreateDeviceAndSwapChain" );
26
-
27
- if (!pD3D11CreateDeviceAndSwapChain)
28
- {
29
- Log (" * DX11: failed to get address of D3D11CreateDeviceAndSwapChain" );
30
- return false ;
31
- }
32
-
33
11
// Register class
34
12
WNDCLASSEX wcex;
35
13
ZeroMemory (&wcex, sizeof (wcex));
@@ -47,16 +25,13 @@ bool TestDX11Present()
47
25
HWND hWnd = CreateWindow (" TestDX11WindowClass" , " " , WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
48
26
CW_USEDEFAULT, CW_USEDEFAULT, NULL , NULL , NULL , NULL );
49
27
50
- DXGI_SWAP_CHAIN_DESC sd;
51
-
52
28
if (!hWnd)
53
29
{
54
30
Msg (" * DX11: failed to create window" );
55
31
return false ;
56
32
}
57
33
58
- HRESULT hr = E_FAIL;
59
-
34
+ DXGI_SWAP_CHAIN_DESC sd;
60
35
ZeroMemory (&sd, sizeof (sd));
61
36
sd.BufferCount = 1 ;
62
37
sd.BufferDesc .Width = 800 ;
@@ -77,20 +52,18 @@ bool TestDX11Present()
77
52
ID3D11DeviceContext* pContext = NULL ;
78
53
IDXGISwapChain* pSwapChain = NULL ;
79
54
80
- hr = pD3D11CreateDeviceAndSwapChain (NULL , D3D_DRIVER_TYPE_HARDWARE, NULL , 0 , pFeatureLevels, 1 , D3D11_SDK_VERSION,
55
+ HRESULT hr = D3D11CreateDeviceAndSwapChain (NULL , D3D_DRIVER_TYPE_HARDWARE, NULL , 0 , pFeatureLevels, 1 , D3D11_SDK_VERSION,
81
56
&sd, &pSwapChain, &pd3dDevice, &FeatureLevel, &pContext);
82
57
83
58
if (FAILED (hr))
84
59
Msg (" * D3D11: device creation failed with hr=0x%08x" , hr);
85
60
86
- if (pContext)
87
- pContext->Release ();
88
- if (pSwapChain)
89
- pSwapChain->Release ();
90
- if (pd3dDevice)
91
- pd3dDevice->Release ();
61
+ _RELEASE (pSwapChain);
62
+ _RELEASE (pd3dDevice);
63
+ _RELEASE (pContext);
92
64
93
65
DestroyWindow (hWnd);
66
+ UnregisterClass (" TestDX11WindowClass" , GetModuleHandle (NULL ));
94
67
95
68
return SUCCEEDED (hr);
96
69
}
0 commit comments