mirror of
https://github.com/reactos/reactos.git
synced 2024-08-02 09:30:55 +00:00
- Implement IDirectDraw7::GetMonitorFrequency, GetDisplayMode
- Outsource display mode related APIs into own file - Some formatting and spelling fixes svn path=/trunk/; revision=26848
This commit is contained in:
parent
f52f59db1d
commit
8bbbeb08ba
107
reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c
Normal file
107
reactos/dll/directx/ddraw/Ddraw/ddraw_displaymode.c
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS DirectX
|
||||||
|
* FILE: ddraw/ddraw/ddraw_displaymode.c
|
||||||
|
* PURPOSE: IDirectDraw7 Implementation
|
||||||
|
* PROGRAMMER: Maarten Bosma
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "rosdraw.h"
|
||||||
|
|
||||||
|
HRESULT WINAPI
|
||||||
|
Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
|
||||||
|
DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
|
||||||
|
{
|
||||||
|
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||||
|
DX_WINDBG_trace();
|
||||||
|
|
||||||
|
// FIXME: Check primary if surface is locked / busy etc.
|
||||||
|
|
||||||
|
// Check Parameter
|
||||||
|
if(dwFlags != 0)
|
||||||
|
{
|
||||||
|
return DDERR_INVALIDPARAMS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((!dwHeight || This->lpLcl->lpGbl->vmiData.dwDisplayHeight == dwHeight) &&
|
||||||
|
(!dwWidth || This->lpLcl->lpGbl->vmiData.dwDisplayWidth == dwWidth) &&
|
||||||
|
(!dwBPP || This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwRGBBitCount == dwBPP) &&
|
||||||
|
(!dwRefreshRate || This->lpLcl->lpGbl->dwMonitorFrequency == dwRefreshRate))
|
||||||
|
{
|
||||||
|
return DD_OK; // nothing to do here for us
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here we go
|
||||||
|
DEVMODE DevMode;
|
||||||
|
DevMode.dmFields = 0;
|
||||||
|
if(dwHeight)
|
||||||
|
DevMode.dmFields |= DM_PELSHEIGHT;
|
||||||
|
if(dwWidth)
|
||||||
|
DevMode.dmFields |= DM_PELSWIDTH;
|
||||||
|
if(dwBPP)
|
||||||
|
DevMode.dmFields |= DM_BITSPERPEL;
|
||||||
|
if(dwRefreshRate)
|
||||||
|
DevMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||||
|
|
||||||
|
DevMode.dmPelsHeight = dwHeight;
|
||||||
|
DevMode.dmPelsWidth = dwWidth;
|
||||||
|
DevMode.dmBitsPerPel = dwBPP;
|
||||||
|
DevMode.dmDisplayFrequency = dwRefreshRate;
|
||||||
|
|
||||||
|
LONG retval = ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN); /* FIXME: Are we supposed to set CDS_SET_PRIMARY as well ? */
|
||||||
|
|
||||||
|
if(retval == DISP_CHANGE_BADMODE)
|
||||||
|
{
|
||||||
|
return DDERR_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
else if(retval != DISP_CHANGE_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
return DDERR_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Interals
|
||||||
|
BOOL ModeChanged;
|
||||||
|
DdReenableDirectDrawObject(This->lpLcl->lpGbl, &ModeChanged);
|
||||||
|
StartDirectDraw((LPDIRECTDRAW)iface, 0, TRUE);
|
||||||
|
|
||||||
|
return DD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI
|
||||||
|
Main_DirectDraw_GetMonitorFrequency (LPDIRECTDRAW7 iface, LPDWORD lpFreq)
|
||||||
|
{
|
||||||
|
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||||
|
DX_WINDBG_trace();
|
||||||
|
|
||||||
|
if (lpFreq == NULL)
|
||||||
|
return DDERR_INVALIDPARAMS;
|
||||||
|
|
||||||
|
*lpFreq = This->lpLcl->lpGbl->dwMonitorFrequency;
|
||||||
|
|
||||||
|
return DD_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI
|
||||||
|
Main_DirectDraw_GetDisplayMode (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
|
||||||
|
{
|
||||||
|
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||||
|
DX_WINDBG_trace();
|
||||||
|
|
||||||
|
if (pDDSD == NULL)
|
||||||
|
return DDERR_INVALIDPARAMS;
|
||||||
|
|
||||||
|
if (pDDSD->dwSize != sizeof(LPDDSURFACEDESC2))
|
||||||
|
return DDERR_INVALIDPARAMS;
|
||||||
|
|
||||||
|
pDDSD->dwFlags |= DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT | DDSD_PITCH | DDSD_REFRESHRATE;
|
||||||
|
pDDSD->dwHeight = This->lpLcl->lpGbl->vmiData.dwDisplayWidth;
|
||||||
|
pDDSD->dwWidth = This->lpLcl->lpGbl->vmiData.dwDisplayHeight;
|
||||||
|
pDDSD->ddpfPixelFormat = This->lpLcl->lpGbl->vmiData.ddpfDisplay;
|
||||||
|
pDDSD->dwRefreshRate = This->lpLcl->lpGbl->dwMonitorFrequency;
|
||||||
|
pDDSD->lPitch = This->lpLcl->lpGbl->vmiData.lDisplayPitch;
|
||||||
|
|
||||||
|
return DD_OK;
|
||||||
|
}
|
|
@ -11,8 +11,7 @@
|
||||||
|
|
||||||
#include "rosdraw.h"
|
#include "rosdraw.h"
|
||||||
|
|
||||||
HRESULT
|
HRESULT WINAPI
|
||||||
WINAPI
|
|
||||||
Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
||||||
REFIID id,
|
REFIID id,
|
||||||
LPVOID *obj)
|
LPVOID *obj)
|
||||||
|
@ -21,8 +20,8 @@ Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
||||||
|
|
||||||
DX_WINDBG_trace();
|
DX_WINDBG_trace();
|
||||||
|
|
||||||
/* fixme
|
/* FIXME
|
||||||
the D3D object cab be optain from here
|
the D3D object can be optained from here
|
||||||
Direct3D7
|
Direct3D7
|
||||||
*/
|
*/
|
||||||
if (IsEqualGUID(&IID_IDirectDraw7, id))
|
if (IsEqualGUID(&IID_IDirectDraw7, id))
|
||||||
|
@ -44,12 +43,7 @@ Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
ULONG WINAPI
|
||||||
* IMPLEMENT
|
|
||||||
* Status ok
|
|
||||||
*/
|
|
||||||
ULONG
|
|
||||||
WINAPI
|
|
||||||
Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
|
Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
|
||||||
{
|
{
|
||||||
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||||
|
@ -69,9 +63,7 @@ Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
|
||||||
return This->dwIntRefCnt;
|
return This->dwIntRefCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ULONG WINAPI
|
||||||
ULONG
|
|
||||||
WINAPI
|
|
||||||
Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
|
Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
|
||||||
{
|
{
|
||||||
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
||||||
|
@ -103,70 +95,16 @@ Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
|
||||||
return This->dwIntRefCnt;
|
return This->dwIntRefCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT
|
HRESULT WINAPI
|
||||||
WINAPI
|
Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
|
||||||
Main_DirectDraw_Compact(LPDIRECTDRAW7 iface)
|
|
||||||
{
|
{
|
||||||
return DD_OK; // not implemented in ms ddraw
|
return DDERR_ALREADYINITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
|
Main_DirectDraw_Compact(LPDIRECTDRAW7 iface)
|
||||||
DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
|
|
||||||
{
|
{
|
||||||
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
|
return DD_OK; // not implemented in ms ddraw either
|
||||||
DX_WINDBG_trace();
|
|
||||||
|
|
||||||
// FIXME: Check primary if surface is locked / busy etc.
|
|
||||||
|
|
||||||
// Check Parameter
|
|
||||||
if(dwFlags != 0)
|
|
||||||
{
|
|
||||||
return DDERR_INVALIDPARAMS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!dwHeight || This->lpLcl->lpGbl->vmiData.dwDisplayHeight == dwHeight) &&
|
|
||||||
(!dwWidth || This->lpLcl->lpGbl->vmiData.dwDisplayWidth == dwWidth) &&
|
|
||||||
(!dwBPP || This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwRGBBitCount == dwBPP) &&
|
|
||||||
(!dwRefreshRate || This->lpLcl->lpGbl->dwMonitorFrequency == dwRefreshRate))
|
|
||||||
{
|
|
||||||
return DD_OK; // nothing to do here for us
|
|
||||||
}
|
|
||||||
|
|
||||||
// Here we go
|
|
||||||
DEVMODE DevMode;
|
|
||||||
DevMode.dmFields = 0;
|
|
||||||
if(dwHeight)
|
|
||||||
DevMode.dmFields |= DM_PELSHEIGHT;
|
|
||||||
if(dwWidth)
|
|
||||||
DevMode.dmFields |= DM_PELSWIDTH;
|
|
||||||
if(dwBPP)
|
|
||||||
DevMode.dmFields |= DM_BITSPERPEL;
|
|
||||||
if(dwRefreshRate)
|
|
||||||
DevMode.dmFields |= DM_DISPLAYFREQUENCY;
|
|
||||||
|
|
||||||
DevMode.dmPelsHeight = dwHeight;
|
|
||||||
DevMode.dmPelsWidth = dwWidth;
|
|
||||||
DevMode.dmBitsPerPel = dwBPP;
|
|
||||||
DevMode.dmDisplayFrequency = dwRefreshRate;
|
|
||||||
|
|
||||||
LONG retval = ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN); /* FIXME: Are we supposed to set CDS_SET_PRIMARY as well ? */
|
|
||||||
|
|
||||||
if(retval == DISP_CHANGE_BADMODE)
|
|
||||||
{
|
|
||||||
return DDERR_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
else if(retval != DISP_CHANGE_SUCCESSFUL)
|
|
||||||
{
|
|
||||||
return DDERR_GENERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Interals
|
|
||||||
BOOL ModeChanged;
|
|
||||||
DdReenableDirectDrawObject(This->lpLcl->lpGbl, &ModeChanged);
|
|
||||||
StartDirectDraw((LPDIRECTDRAW)iface, 0, TRUE);
|
|
||||||
|
|
||||||
return DD_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
|
@ -204,8 +142,9 @@ Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
|
||||||
return memdata.ddRVal;
|
return memdata.ddRVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
|
HRESULT WINAPI
|
||||||
LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter)
|
Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD,
|
||||||
|
LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter)
|
||||||
{
|
{
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
DDSURFACEDESC2 dd_desc_v2;
|
DDSURFACEDESC2 dd_desc_v2;
|
||||||
|
@ -258,7 +197,7 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check if this process belong to this ddraw */
|
/* Check if this process belongs to this ddraw object */
|
||||||
if ( dd_int->lpLcl->dwProcessId != GetCurrentProcessId() )
|
if ( dd_int->lpLcl->dwProcessId != GetCurrentProcessId() )
|
||||||
{
|
{
|
||||||
/* FIXME send back right return code */
|
/* FIXME send back right return code */
|
||||||
|
@ -272,7 +211,6 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IDirectDraw7Vtbl DirectDraw7_Vtable =
|
IDirectDraw7Vtbl DirectDraw7_Vtable =
|
||||||
{
|
{
|
||||||
Main_DirectDraw_QueryInterface,
|
Main_DirectDraw_QueryInterface,
|
||||||
|
|
|
@ -78,15 +78,6 @@ Main_DirectDraw_GetCaps(LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
|
||||||
DX_STUB;
|
DX_STUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Status: Implentation removed due to rewrite
|
|
||||||
*/
|
|
||||||
HRESULT WINAPI Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD)
|
|
||||||
{
|
|
||||||
DX_WINDBG_trace();
|
|
||||||
DX_STUB;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
|
Main_DirectDraw_GetFourCCCodes(LPDIRECTDRAW7 iface, LPDWORD pNumCodes, LPDWORD pCodes)
|
||||||
{
|
{
|
||||||
|
@ -102,13 +93,6 @@ Main_DirectDraw_GetGDISurface(LPDIRECTDRAW7 iface,
|
||||||
DX_STUB;
|
DX_STUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI
|
|
||||||
Main_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq)
|
|
||||||
{
|
|
||||||
DX_WINDBG_trace();
|
|
||||||
DX_STUB;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT WINAPI
|
HRESULT WINAPI
|
||||||
Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
|
Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
|
||||||
{
|
{
|
||||||
|
@ -123,17 +107,6 @@ Main_DirectDraw_GetVerticalBlankStatus(LPDIRECTDRAW7 iface, LPBOOL lpbIsInVB)
|
||||||
DX_STUB;
|
DX_STUB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Status: Implentation removed due to rewrite
|
|
||||||
*/
|
|
||||||
HRESULT
|
|
||||||
WINAPI
|
|
||||||
Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID)
|
|
||||||
{
|
|
||||||
DX_WINDBG_trace();
|
|
||||||
DX_STUB;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Status: Implentation removed due to rewrite
|
* Status: Implentation removed due to rewrite
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,9 +23,10 @@
|
||||||
<file>cleanup.c</file>
|
<file>cleanup.c</file>
|
||||||
|
|
||||||
<directory name="Ddraw">
|
<directory name="Ddraw">
|
||||||
<file>ddraw_stubs.c</file>
|
|
||||||
<file>ddraw_setcooperativelevel.c</file>
|
|
||||||
<file>ddraw_main.c</file>
|
<file>ddraw_main.c</file>
|
||||||
|
<file>ddraw_displaymode.c</file>
|
||||||
|
<file>ddraw_setcooperativelevel.c</file>
|
||||||
|
<file>ddraw_stubs.c</file>
|
||||||
<file>callbacks_dd_hel.c</file>
|
<file>callbacks_dd_hel.c</file>
|
||||||
</directory>
|
</directory>
|
||||||
<directory name="Surface">
|
<directory name="Surface">
|
||||||
|
|
Loading…
Reference in a new issue