4949
5050using namespace Diligent ;
5151
52- namespace Diligent
53- {
54- #if ENGINE_DLL
55- # if D3D11_SUPPORTED
56- GetEngineFactoryD3D11Type GetEngineFactoryD3D11 = nullptr ;
57- # endif
58-
59- # if D3D12_SUPPORTED
60- GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr ;
61- # endif
62-
63- # if GL_SUPPORTED
64- GetEngineFactoryOpenGLType GetEngineFactoryOpenGL = nullptr ;
65- # endif
66-
67- # if VULKAN_SUPPORTED
68- GetEngineFactoryVkType GetEngineFactoryVulkan = nullptr ;
69- # endif
70- #endif
71- } // namespace Diligent
72-
7352namespace AsteroidsDE
7453{
7554
@@ -118,11 +97,7 @@ void Asteroids::InitDevice(HWND hWnd, RENDER_DEVICE_TYPE DevType)
11897 EngineD3D11CreateInfo EngineCI;
11998 EngineCI.NumDeferredContexts = mNumSubsets - 1 ;
12099
121- # if ENGINE_DLL
122- if (GetEngineFactoryD3D11 == nullptr )
123- GetEngineFactoryD3D11 = LoadGraphicsEngineD3D11 ();
124- # endif
125- auto * pFactoryD3D11 = GetEngineFactoryD3D11 ();
100+ auto * pFactoryD3D11 = LoadAndGetEngineFactoryD3D11 ();
126101 pFactoryD3D11->CreateDeviceAndContextsD3D11 (EngineCI, &mDevice , ppContexts.data ());
127102 pFactoryD3D11->CreateSwapChainD3D11 (mDevice , ppContexts[0 ], SwapChainDesc, FullScreenModeDesc{}, Win32NativeWindow{hWnd}, &mSwapChain );
128103 }
@@ -140,11 +115,8 @@ void Asteroids::InitDevice(HWND hWnd, RENDER_DEVICE_TYPE DevType)
140115# ifndef DILIGENT_DEBUG
141116 EngineCI.DynamicDescriptorAllocationChunkSize [0 ] = 8192 ;
142117# endif
143- # if ENGINE_DLL
144- if (GetEngineFactoryD3D12 == nullptr )
145- GetEngineFactoryD3D12 = LoadGraphicsEngineD3D12 ();
146- # endif
147- auto * pFactoryD3D12 = GetEngineFactoryD3D12 ();
118+
119+ auto * pFactoryD3D12 = LoadAndGetEngineFactoryD3D12 ();
148120 pFactoryD3D12->CreateDeviceAndContextsD3D12 (EngineCI, &mDevice , ppContexts.data ());
149121 pFactoryD3D12->CreateSwapChainD3D12 (mDevice , ppContexts[0 ], SwapChainDesc, FullScreenModeDesc{}, Win32NativeWindow{hWnd}, &mSwapChain );
150122 }
@@ -169,11 +141,7 @@ void Asteroids::InitDevice(HWND hWnd, RENDER_DEVICE_TYPE DevType)
169141 EngineCI.ppIgnoreDebugMessageNames = ppIgnoreDebugMessages;
170142 EngineCI.IgnoreDebugMessageCount = _countof (ppIgnoreDebugMessages);
171143
172- # if ENGINE_DLL
173- if (GetEngineFactoryVulkan == nullptr )
174- GetEngineFactoryVulkan = LoadGraphicsEngineVk ();
175- # endif
176- auto * pFactoryVk = GetEngineFactoryVulkan ();
144+ auto * pFactoryVk = LoadAndGetEngineFactoryVk ();
177145 pFactoryVk->CreateDeviceAndContextsVk (EngineCI, &mDevice , ppContexts.data ());
178146 pFactoryVk->CreateSwapChainVk (mDevice , ppContexts[0 ], SwapChainDesc, Win32NativeWindow{hWnd}, &mSwapChain );
179147 }
@@ -184,13 +152,11 @@ void Asteroids::InitDevice(HWND hWnd, RENDER_DEVICE_TYPE DevType)
184152#if GL_SUPPORTED
185153 case RENDER_DEVICE_TYPE_GL:
186154 {
187- # if ENGINE_DLL
188- if (GetEngineFactoryOpenGL == nullptr )
189- GetEngineFactoryOpenGL = LoadGraphicsEngineOpenGL ();
190- # endif
191155 EngineGLCreateInfo CreationAttribs;
192156 CreationAttribs.Window .hWnd = hWnd;
193- GetEngineFactoryOpenGL ()->CreateDeviceAndSwapChainGL (
157+
158+ auto * pFactoryGL = LoadAndGetEngineFactoryOpenGL ();
159+ pFactoryGL->CreateDeviceAndSwapChainGL (
194160 CreationAttribs, &mDevice , &mDeviceCtxt , SwapChainDesc, &mSwapChain );
195161 }
196162 break ;
0 commit comments