Michael Karcher : ddraw: Ensure to load wined3d before attempting to create a clipper.
Alexandre Julliard
julliard at winehq.org
Mon Jun 23 07:36:06 CDT 2008
Module: wine
Branch: master
Commit: 606186d4c5f1942e74c1bb1c563ea91252cfee8f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=606186d4c5f1942e74c1bb1c563ea91252cfee8f
Author: Michael Karcher <wine at mkarcher.dialup.fu-berlin.de>
Date: Sat Jun 21 16:02:49 2008 +0200
ddraw: Ensure to load wined3d before attempting to create a clipper.
---
dlls/ddraw/ddraw.c | 6 ++++++
dlls/ddraw/ddraw_private.h | 3 +++
dlls/ddraw/main.c | 38 ++++++++++++++++++++++++++------------
3 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index ab78c4b..dfd77fa 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -3241,6 +3241,12 @@ DirectDrawCreateClipper(DWORD Flags,
return CLASS_E_NOAGGREGATION;
}
+ if (!LoadWineD3D())
+ {
+ LeaveCriticalSection(&ddraw_cs);
+ return DDERR_NODIRECTDRAWSUPPORT;
+ }
+
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(IDirectDrawClipperImpl));
if (object == NULL)
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index f256c50..9842260 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -644,6 +644,9 @@ void DDRAW_dump_cooperativelevel(DWORD cooplevel);
* IDirect3DExecuteBuffer isn't in WineD3D */
void multiply_matrix(LPD3DMATRIX dest, const D3DMATRIX *src1, const D3DMATRIX *src2);
+/* Helper function in main.c */
+BOOL LoadWineD3D(void);
+
/* Used for generic dumping */
typedef struct
{
diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c
index ac1378d..d03a89c 100644
--- a/dlls/ddraw/main.c
+++ b/dlls/ddraw/main.c
@@ -49,7 +49,6 @@
typedef IWineD3D* (WINAPI *fnWineDirect3DCreate)(UINT, UINT, IUnknown *);
-static HMODULE hWineD3D = (HMODULE) -1;
static fnWineDirect3DCreate pWineDirect3DCreate;
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
@@ -72,6 +71,31 @@ CRITICAL_SECTION ddraw_cs = { &ddraw_cs_debug, -1, 0, 0, 0, 0 };
/* value of ForceRefreshRate */
DWORD force_refresh_rate = 0;
+/*
+ * Helper Function for DDRAW_Create and DirectDrawCreateClipper for
+ * lazy loading of the Wine D3D driver.
+ *
+ * Returns
+ * TRUE on success
+ * FALSE on failure.
+ */
+
+BOOL LoadWineD3D(void)
+{
+ static HMODULE hWineD3D = (HMODULE) -1;
+ if (hWineD3D == (HMODULE) -1)
+ {
+ hWineD3D = LoadLibraryA("wined3d");
+ if (hWineD3D)
+ {
+ pWineDirect3DCreate = (fnWineDirect3DCreate) GetProcAddress(hWineD3D, "WineDirect3DCreate");
+ pWineDirect3DCreateClipper = (fnWineDirect3DCreateClipper) GetProcAddress(hWineD3D, "WineDirect3DCreateClipper");
+ return TRUE;
+ }
+ }
+ return hWineD3D != NULL;
+}
+
/***********************************************************************
*
* Helper function for DirectDrawCreate and friends
@@ -171,17 +195,7 @@ DDRAW_Create(const 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");
- pWineDirect3DCreateClipper = (fnWineDirect3DCreateClipper) GetProcAddress(hWineD3D, "WineDirect3DCreateClipper");
- }
- }
-
- if (!hWineD3D)
+ if (!LoadWineD3D())
{
ERR("Couldn't load WineD3D - OpenGL libs not present?\n");
hr = DDERR_NODIRECTDRAWSUPPORT;
More information about the wine-cvs
mailing list