From 29de9009cd84b2fc4f74e432c09708e2ce0eca88 Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Sun, 30 Oct 2005 09:45:10 +0000 Subject: [PATCH] Move hel SetDisplayMode to hel and write a stub for hal SetDisplayMode. Hel SetDisplayMode is already implmenet by DrFred svn path=/trunk/; revision=18874 --- reactos/lib/ddraw/hal/ddraw.c | 32 ++++++++++++++++++++++- reactos/lib/ddraw/main/ddraw.c | 15 +++++++++++ reactos/lib/ddraw/rosdraw.h | 5 ++++ reactos/lib/ddraw/soft/ddraw.c | 46 ++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/reactos/lib/ddraw/hal/ddraw.c b/reactos/lib/ddraw/hal/ddraw.c index a8e6c0ef4d2..d1ac6e58bc0 100644 --- a/reactos/lib/ddraw/hal/ddraw.c +++ b/reactos/lib/ddraw/hal/ddraw.c @@ -454,5 +454,35 @@ HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) } /* FIXME where should FlipGdi.dwToGDI be fill in */ - return FlipGdi.ddRVal; + return FlipGdi.ddRVal; +} + +HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) +{ + DDHAL_SETMODEDATA mode; + + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETMODE)) + { + return DDERR_NODRIVERSUPPORT; + } + + mode.lpDD = &This->DirectDrawGlobal; + mode.ddRVal = DDERR_NODRIVERSUPPORT; + + /* FIXME : add search for which mode.ModeIndex we should use */ + /* FIXME : fill the mode.inexcl; */ + /* FIXME : fill the mode.useRefreshRate; */ + + /* + if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.SetMode(&mode) != DDHAL_DRIVER_HANDLED) + { + return DDERR_NODRIVERSUPPORT; + } + */ + + DX_STUB; + /* return mode.ddRVal */ } diff --git a/reactos/lib/ddraw/main/ddraw.c b/reactos/lib/ddraw/main/ddraw.c index 4c5765f0b01..dbbf5d3b30c 100644 --- a/reactos/lib/ddraw/main/ddraw.c +++ b/reactos/lib/ddraw/main/ddraw.c @@ -85,6 +85,21 @@ HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hw HRESULT WINAPI Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) { + DWORD ret; + if((ret = Hal_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, + dwBPP, dwRefreshRate, dwFlags)) == DD_OK) + { + return ret; + } + + if((ret = Hel_DirectDraw_SetDisplayMode(iface, dwWidth, dwHeight, + dwBPP, dwRefreshRate, dwFlags)) == DD_OK) + { + return ret; + } + + return DDERR_NOTINITIALIZED; + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; // this only for exclusive mode diff --git a/reactos/lib/ddraw/rosdraw.h b/reactos/lib/ddraw/rosdraw.h index e6eccbec4fb..d19c522763c 100644 --- a/reactos/lib/ddraw/rosdraw.h +++ b/reactos/lib/ddraw/rosdraw.h @@ -96,6 +96,9 @@ HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT Hal_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine); HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface); +HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags); + @@ -112,6 +115,8 @@ HRESULT Hel_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags, HRESULT Hel_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine); HRESULT Hel_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface); +HRESULT Hel_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags); /*********** Macros ***********/ diff --git a/reactos/lib/ddraw/soft/ddraw.c b/reactos/lib/ddraw/soft/ddraw.c index 31724257f4b..fe20977f215 100644 --- a/reactos/lib/ddraw/soft/ddraw.c +++ b/reactos/lib/ddraw/soft/ddraw.c @@ -48,3 +48,49 @@ HRESULT Hel_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) DX_STUB; } +HRESULT Hel_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, + DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) +{ + IDirectDrawImpl* This = (IDirectDrawImpl*)iface; + + // this only for exclusive mode + if(!(This->cooperative_level & DDSCL_EXCLUSIVE)) + return DDERR_NOEXCLUSIVEMODE; + + // change the resolution using normal WinAPI function + DEVMODE mode; + mode.dmSize = sizeof(mode); + mode.dmPelsWidth = dwWidth; + mode.dmPelsHeight = dwHeight; + mode.dmBitsPerPel = dwBPP; + mode.dmDisplayFrequency = dwRefreshRate; + mode.dmFields = 0; + + if(dwWidth) + mode.dmFields |= DM_PELSWIDTH; + if(dwHeight) + mode.dmFields |= DM_PELSHEIGHT; + if(dwBPP) + mode.dmFields |= DM_BITSPERPEL; + if(dwRefreshRate) + mode.dmFields |= DM_DISPLAYFREQUENCY; + + if (ChangeDisplaySettings(&mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) + return DDERR_UNSUPPORTEDMODE; + + // TODO: reactivate ddraw object, maximize window, set it in foreground + // and set excluive mode (if implemented by the driver) + + /* FIXME fill the DirectDrawGlobal right the modeindex old and new */ + + if(dwWidth) + This->Height = dwWidth; + if(dwHeight) + This->Width = dwHeight; + if(dwBPP) + This->Bpp = dwBPP; + + return DD_OK; +} + +