ddraw: Don't link to wined3d, load it at runtime.

This lets ddraw dlls built on a machine with OpenGL present run on other 
machines that may not have the OpenGL libraries installed.
This commit is contained in:
Mike McCormack 2006-08-03 14:30:00 +09:00 committed by Alexandre Julliard
parent 3538c0cdce
commit d99c7d5939
2 changed files with 21 additions and 2 deletions

View File

@ -4,7 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = ddraw.dll
IMPORTLIB = libddraw.$(IMPLIBEXT)
IMPORTS = wined3d ole32 user32 gdi32 advapi32 kernel32 ntdll
IMPORTS = ole32 user32 gdi32 advapi32 kernel32 ntdll
EXTRAINCL = @X_CFLAGS@
EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@

View File

@ -48,6 +48,11 @@
#include "ddraw_private.h"
typedef IWineD3D* (WINAPI *fnWineDirect3DCreate)(UINT, UINT, IUnknown *);
static HMODULE hWineD3D = (HMODULE) -1;
static fnWineDirect3DCreate pWineDirect3DCreate;
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
/* The configured default surface */
@ -149,13 +154,27 @@ DDRAW_Create(GUID *guid,
This->orig_width = GetSystemMetrics(SM_CXSCREEN);
This->orig_height = GetSystemMetrics(SM_CYSCREEN);
if (hWineD3D == (HMODULE) -1)
{
hWineD3D = LoadLibraryA("wined3d");
if (hWineD3D)
pWineDirect3DCreate = (fnWineDirect3DCreate) GetProcAddress(hWineD3D, "WineDirect3DCreate");
}
if (!hWineD3D)
{
ERR("Couldn't load WineD3D - OpenGL libs not present?\n");
hr = E_NOTIMPL;
goto err_out;
}
/* Initialize WineD3D
*
* All Rendering (2D and 3D) is relayed to WineD3D,
* but DirectDraw specific management, like DDSURFACEDESC and DDPIXELFORMAT
* structure handling is handled in this lib.
*/
wineD3D = WineDirect3DCreate(0 /* SDKVersion */, 7 /* DXVersion */, (IUnknown *) This /* Parent */);
wineD3D = pWineDirect3DCreate(0 /* SDKVersion */, 7 /* DXVersion */, (IUnknown *) This /* Parent */);
if(!wineD3D)
{
ERR("Failed to initialise WineD3D\n");