diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c index 25e71fa6660..a7ec624e29b 100644 --- a/dlls/ddraw/clipper.c +++ b/dlls/ddraw/clipper.c @@ -283,7 +283,7 @@ static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged( /***************************************************************************** * The VTable *****************************************************************************/ -const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl = +static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl = { IDirectDrawClipperImpl_QueryInterface, IDirectDrawClipperImpl_AddRef, @@ -295,3 +295,17 @@ const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl = IDirectDrawClipperImpl_SetClipList, IDirectDrawClipperImpl_SetHwnd }; + +HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) +{ + clipper->lpVtbl = &ddraw_clipper_vtbl; + clipper->ref = 1; + clipper->wineD3DClipper = pWineDirect3DCreateClipper((IUnknown *)clipper); + if (!clipper->wineD3DClipper) + { + WARN("Failed to create wined3d clipper.\n"); + return E_OUTOFMEMORY; + } + + return DD_OK; +} diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index df79f0e99e5..20f31ee9d3e 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -3840,6 +3840,8 @@ DirectDrawCreateClipper(DWORD Flags, IUnknown *UnkOuter) { IDirectDrawClipperImpl* object; + HRESULT hr; + TRACE("(%08x,%p,%p)\n", Flags, Clipper, UnkOuter); EnterCriticalSection(&ddraw_cs); @@ -3863,16 +3865,16 @@ DirectDrawCreateClipper(DWORD Flags, return E_OUTOFMEMORY; } - object->lpVtbl = &IDirectDrawClipper_Vtbl; - object->ref = 1; - object->wineD3DClipper = pWineDirect3DCreateClipper((IUnknown *) object); - if(!object->wineD3DClipper) + hr = ddraw_clipper_init(object); + if (FAILED(hr)) { + WARN("Failed to initialize clipper, hr %#x.\n", hr); HeapFree(GetProcessHeap(), 0, object); LeaveCriticalSection(&ddraw_cs); - return E_OUTOFMEMORY; + return hr; } + TRACE("Created clipper %p.\n", object); *Clipper = (IDirectDrawClipper *) object; LeaveCriticalSection(&ddraw_cs); return DD_OK; diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 40f3bfdc098..6341f3f8c5e 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -462,7 +462,7 @@ struct IDirectDrawClipperImpl BOOL initialized; }; -extern const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl DECLSPEC_HIDDEN; +HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper) DECLSPEC_HIDDEN; typeof(WineDirect3DCreateClipper) *pWineDirect3DCreateClipper DECLSPEC_HIDDEN;