|
77 | 77 | #include "bound.h" |
78 | 78 | #include "ini.h" |
79 | 79 | #include "openw3d.h" |
| 80 | +#include "soutil.h" |
80 | 81 |
|
81 | 82 | const int DEFAULT_RESOLUTION_WIDTH = 800; |
82 | 83 | const int DEFAULT_RESOLUTION_HEIGHT = 600; |
@@ -170,14 +171,28 @@ static DynamicVectorClass<RenderDeviceDescClass> _RenderDeviceDescriptionTable; |
170 | 171 |
|
171 | 172 | typedef IDirect3D9* (WINAPI *Direct3DCreate8Type) (UINT SDKVersion); |
172 | 173 | Direct3DCreate8Type Direct3DCreate8Ptr = NULL; |
173 | | -HINSTANCE D3D8Lib = NULL; |
| 174 | +SharedObject *D3D9Lib = nullptr; |
174 | 175 |
|
175 | 176 | /*********************************************************************************** |
176 | 177 | ** |
177 | 178 | ** DX8Wrapper Implementation |
178 | 179 | ** |
179 | 180 | ***********************************************************************************/ |
180 | 181 |
|
| 182 | +const char *Get_D3D9_Object_Name() |
| 183 | +{ |
| 184 | + // FIXME: support overriding object using config (args, ini, register, envvar) |
| 185 | +#ifdef _WIN32 |
| 186 | + return "d3d9.dll"; |
| 187 | +#elif defined (__ELF__) |
| 188 | + return "libdxvk_d3d9.so.0"; |
| 189 | +#elif defined (__MACH__) |
| 190 | + return "libdxvk_d3d9.0.dylib"; |
| 191 | +#else |
| 192 | + static_assert(false, "Unknown d3d9 name"); |
| 193 | +#endif |
| 194 | +} |
| 195 | + |
181 | 196 | void Log_DX8_ErrorCode(HRESULT res) |
182 | 197 | { |
183 | 198 | const char *error_string = DXGetErrorStringA(res); |
@@ -240,11 +255,11 @@ bool DX8Wrapper::Init(void * hwnd, bool lite) |
240 | 255 | Invalidate_Cached_Render_States(); |
241 | 256 |
|
242 | 257 | if (!lite) { |
243 | | - D3D8Lib = LoadLibraryA("D3D9.DLL"); |
| 258 | + D3D9Lib = SharedObject::LoadObject(Get_D3D9_Object_Name()); |
244 | 259 |
|
245 | | - if (D3D8Lib == NULL) return false; |
| 260 | + if (D3D9Lib == NULL) return false; |
246 | 261 |
|
247 | | - Direct3DCreate8Ptr = (Direct3DCreate8Type) GetProcAddress(D3D8Lib, "Direct3DCreate9"); |
| 262 | + Direct3DCreate8Ptr = reinterpret_cast<Direct3DCreate8Type>(D3D9Lib->LoadFunction("Direct3DCreate9")); |
248 | 263 | if (Direct3DCreate8Ptr) { |
249 | 264 |
|
250 | 265 | /* |
@@ -311,9 +326,9 @@ void DX8Wrapper::Shutdown(void) |
311 | 326 | _RenderDeviceShortNameTable.Delete_All(); |
312 | 327 | _RenderDeviceDescriptionTable.Delete_All(); |
313 | 328 |
|
314 | | - if (D3D8Lib) { |
315 | | - FreeLibrary(D3D8Lib); |
316 | | - D3D8Lib = NULL; |
| 329 | + if (D3D9Lib) { |
| 330 | + delete D3D9Lib; |
| 331 | + D3D9Lib = NULL; |
317 | 332 | } |
318 | 333 |
|
319 | 334 | IsInitted = false; |
|
0 commit comments