ddraw: Ensure to load wined3d before attempting to create a clipper.

This commit is contained in:
Michael Karcher 2008-06-21 16:02:49 +02:00 committed by Alexandre Julliard
parent ebe7739987
commit 606186d4c5
3 changed files with 35 additions and 12 deletions

View File

@ -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)

View File

@ -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
{

View File

@ -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;