summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/d3d/d3d9intf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render/d3d/d3d9intf.cpp')
-rw-r--r--src/osd/modules/render/d3d/d3d9intf.cpp63
1 files changed, 12 insertions, 51 deletions
diff --git a/src/osd/modules/render/d3d/d3d9intf.cpp b/src/osd/modules/render/d3d/d3d9intf.cpp
index 435ec7ef64c..08eaaff0c7b 100644
--- a/src/osd/modules/render/d3d/d3d9intf.cpp
+++ b/src/osd/modules/render/d3d/d3d9intf.cpp
@@ -64,65 +64,27 @@ static inline void convert_present_params(const present_parameters *params, D3DP
d3d_base *drawd3d9_init(void)
{
- bool post_available = true;
+ // allocate an object to hold our data
+ d3d_base *d3dptr = global_alloc(d3d_base);
- // dynamically grab the create function from d3d9.dll
- HINSTANCE dllhandle = LoadLibrary(TEXT("d3d9.dll"));
- if (dllhandle == nullptr)
- {
- osd_printf_verbose("Direct3D: Unable to access d3d9.dll\n");
- return nullptr;
- }
+ d3dptr->d3d9_dll = osd::dynamic_module::open({ "d3d9.dll" });
- // import the create function
- direct3dcreate9_ptr direct3dcreate9 = (direct3dcreate9_ptr)GetProcAddress(dllhandle, "Direct3DCreate9");
- if (direct3dcreate9 == nullptr)
+ d3d9_create_fn d3d9_create_ptr = d3dptr->d3d9_dll->bind<d3d9_create_fn>("Direct3DCreate9");
+ if (d3d9_create_ptr == nullptr)
{
- osd_printf_verbose("Direct3D: Unable to find Direct3DCreate9\n");
- FreeLibrary(dllhandle);
- return nullptr;
+ osd_printf_verbose("Direct3D: Unable to find Direct3D 9 runtime library\n");
+ return true;
}
- // create our core direct 3d object
- IDirect3D9 *d3d9 = (*direct3dcreate9)(D3D_SDK_VERSION);
- if (d3d9 == nullptr)
+ d3dptr->d3dobj = (*d3d9_create_ptr)(D3D_SDK_VERSION);
+ if (d3dptr->d3dobj == nullptr)
{
- osd_printf_verbose("Direct3D: Error attempting to initialize Direct3D9\n");
- FreeLibrary(dllhandle);
- return nullptr;
+ osd_printf_verbose("Direct3D: Unable to initialize Direct3D 9\n");
+ return true;
}
- // dynamically grab the shader load function from d3dx9.dll
- HINSTANCE fxhandle = nullptr;
- for (int idx = 99; idx >= 0; idx--) // a shameful moogle
- {
- #ifdef UNICODE
- wchar_t dllbuf[13];
- wsprintf(dllbuf, TEXT("d3dx9_%d.dll"), idx);
- fxhandle = LoadLibrary(dllbuf);
- #else
- char dllbuf[13];
- sprintf(dllbuf, "d3dx9_%d.dll", idx);
- fxhandle = LoadLibraryA(dllbuf);
- #endif
- if (fxhandle != nullptr)
- {
- break;
- }
- }
- if (fxhandle == nullptr)
- {
- osd_printf_verbose("Direct3D: Warning - Unable find any D3D9 DLLs; disabling post-effect rendering\n");
- post_available = false;
- }
-
- // allocate an object to hold our data
- auto d3dptr = global_alloc(d3d_base);
d3dptr->version = 9;
- d3dptr->d3dobj = d3d9;
- d3dptr->dllhandle = dllhandle;
- d3dptr->post_fx_available = post_available;
- d3dptr->libhandle = fxhandle;
+ d3dptr->post_fx_available = true;
set_interfaces(d3dptr);
osd_printf_verbose("Direct3D: Using Direct3D 9\n");
@@ -239,7 +201,6 @@ static ULONG release(d3d_base *d3dptr)
{
IDirect3D9 *d3d9 = (IDirect3D9 *)d3dptr->d3dobj;
ULONG result = IDirect3D9_Release(d3d9);
- FreeLibrary(d3dptr->dllhandle);
global_free(d3dptr);
return result;
}