diff --git a/reactos/lib/ddraw/hal/ddraw_hal.c b/reactos/lib/ddraw/hal/ddraw_hal.c index 8b769e8ed00..f00d010742f 100644 --- a/reactos/lib/ddraw/hal/ddraw_hal.c +++ b/reactos/lib/ddraw/hal/ddraw_hal.c @@ -319,6 +319,33 @@ HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface) + /* */ + /* DWORD dwIntRefCnt; + + + LPVOID lpVtbl; + LPDDRAWI_DDRAWSURFACE_LCL lpLcl; + LPDDRAWI_DDRAWSURFACE_INT lpLink; + + } DDRAWI_DDRAWSURFACE_INT; + */ + + /* Setting up some part for surface not ever thing are being fill in yet */ + This->DirectDrawGlobal.dsList = (LPDDRAWI_DDRAWSURFACE_INT)HeapAlloc(GetProcessHeap(), 0, + sizeof(DDRAWI_DDRAWSURFACE_INT)); + + This->DirectDrawGlobal.dsList->lpLink = (LPDDRAWI_DDRAWSURFACE_INT) &This->DirectDrawGlobal.dsList; + + This->DirectDrawGlobal.dsList->lpLcl = (LPDDRAWI_DDRAWSURFACE_LCL)HeapAlloc(GetProcessHeap(), 0, + sizeof(DDRAWI_DDRAWSURFACE_LCL)); + + This->DirectDrawGlobal.dsList->lpLcl->lpGbl = + (LPDDRAWI_DDRAWSURFACE_GBL)HeapAlloc(GetProcessHeap(), 0, sizeof(DDRAWI_DDRAWSURFACE_GBL)); + + This->DirectDrawGlobal.dsList->lpLcl->lpGbl->lpDD = &This->DirectDrawGlobal; + + + /* Now all setup for HAL is done and we hopply do not have forget anything */ @@ -328,7 +355,25 @@ HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface) HRESULT Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface) { - return DD_OK; + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode; + + if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE)) + { + return DDERR_NODRIVERSUPPORT; + } + + SetExclusiveMode.lpDD = &This->DirectDrawGlobal; + SetExclusiveMode.ddRVal = DDERR_NOTPALETTIZED; + SetExclusiveMode.dwEnterExcl = This->cooperative_level; + + if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.SetExclusiveMode(&SetExclusiveMode) != DDHAL_DRIVER_HANDLED) + { + return DDERR_NODRIVERSUPPORT; + } + + return SetExclusiveMode.ddRVal; } diff --git a/reactos/lib/ddraw/main/ddraw_main.c b/reactos/lib/ddraw/main/ddraw_main.c index 3a8b4b87a5f..e064ce2eca6 100644 --- a/reactos/lib/ddraw/main/ddraw_main.c +++ b/reactos/lib/ddraw/main/ddraw_main.c @@ -16,6 +16,8 @@ HRESULT WINAPI Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID) IDirectDrawImpl* This = (IDirectDrawImpl*)iface; HRESULT ret; + + // this if it is not called by DirectDrawCreate if(FALSE) return DDERR_ALREADYINITIALIZED; @@ -48,7 +50,6 @@ HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hw // - allow more Flags IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - HRESULT ret; // check the parameters if (This->cooperative_level == cooplevel && This->window == hwnd) @@ -72,20 +73,21 @@ HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hw This->cooperative_level = cooplevel; + if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE) + { + return Hal_DirectDraw_SetCooperativeLevel (iface); + } - if((ret = Hal_DirectDraw_SetCooperativeLevel (iface)) != DD_OK) - return ret; + return Hel_DirectDraw_SetCooperativeLevel(iface); - if((ret = Hel_DirectDraw_SetCooperativeLevel (iface)) != DD_OK) - return ret; - - return DD_OK; } HRESULT WINAPI Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) { DWORD ret; + + /* FIXME implement hal setMode */ if((ret = Hal_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, dwBPP, dwRefreshRate, dwFlags)) == DD_OK) { @@ -174,7 +176,11 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE That->lpVtbl = &DirectDrawSurface7_Vtable; That->lpVtbl_v3 = &DDRAW_IDDS3_Thunk_VTable; - That->ref = 1; + + That->owner->DirectDrawGlobal.dsList->dwIntRefCnt =1; + + /* we alwasy set to use the DirectDrawSurface7_Vtable as internel */ + That->owner->DirectDrawGlobal.dsList->lpVtbl = (PVOID) &DirectDrawSurface7_Vtable; *ppSurf = (LPDIRECTDRAWSURFACE7)That; diff --git a/reactos/lib/ddraw/rosdraw.h b/reactos/lib/ddraw/rosdraw.h index 05245c77a11..f7b1e0160b6 100644 --- a/reactos/lib/ddraw/rosdraw.h +++ b/reactos/lib/ddraw/rosdraw.h @@ -38,13 +38,7 @@ typedef struct { IDirectDrawSurface7Vtbl* lpVtbl; IDirectDrawSurface3Vtbl* lpVtbl_v3; - - LONG ref; - - DDRAWI_DDRAWSURFACE_GBL Global; - DDRAWI_DDRAWSURFACE_MORE More; - DDRAWI_DDRAWSURFACE_LCL Local; - + IDirectDrawImpl* owner; } IDirectDrawSurfaceImpl;