Author: gbrunmar
Date: Tue Feb 12 20:30:32 2008
New Revision: 32326
URL:
http://svn.reactos.org/svn/reactos?rev=32326&view=rev
Log:
Implemented IDirect3D9::GetAdapterDisplayMode()
Modified:
trunk/reactos/dll/directx/d3d9/adapter.c
trunk/reactos/dll/directx/d3d9/adapter.h
trunk/reactos/dll/directx/d3d9/d3d9_impl.c
trunk/reactos/dll/directx/d3d9/d3d9_private.h
Modified: trunk/reactos/dll/directx/d3d9/adapter.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/adapter.c…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/adapter.c (original)
+++ trunk/reactos/dll/directx/d3d9/adapter.c Tue Feb 12 20:30:32 2008
@@ -169,6 +169,96 @@
+static D3DFORMAT Get16BitD3DFormat(LPCSTR lpszDeviceName)
+{
+ HDC hDC;
+ HBITMAP hBitmap;
+ LPBITMAPINFO pBitmapInfo;
+ D3DFORMAT Format = D3DFMT_R5G6B5;
+
+ if (NULL == (hDC = CreateDCA(NULL, lpszDeviceName, NULL, NULL)))
+ {
+ return Format;
+ }
+
+ if (NULL == (hBitmap = CreateCompatibleBitmap(hDC, 1, 1)))
+ {
+ DeleteDC(hDC);
+ return Format;
+ }
+
+ pBitmapInfo = LocalAlloc(LMEM_ZEROINIT, sizeof(BITMAPINFOHEADER) + 4 *
sizeof(RGBQUAD));
+ if (NULL == pBitmapInfo)
+ {
+ DeleteObject(hBitmap);
+ DeleteDC(hDC);
+ return Format;
+ }
+
+ pBitmapInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ if (GetDIBits(hDC, hBitmap, 0, 0, NULL, pBitmapInfo, DIB_RGB_COLORS) > 0)
+ {
+ if (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS)
+ {
+ if (GetDIBits(hDC, hBitmap, 0, pBitmapInfo->bmiHeader.biHeight, NULL,
pBitmapInfo, DIB_RGB_COLORS) > 0)
+ {
+ /* Check if the green field is 6 bits long */
+ if (*(DWORD*)(&pBitmapInfo->bmiColors[1]) == 0x000003E0)
+ {
+ Format = D3DFMT_X1R5G5B5;
+ }
+ }
+ }
+ }
+
+ LocalFree(pBitmapInfo);
+ DeleteObject(hBitmap);
+ DeleteDC(hDC);
+
+ return Format;
+}
+
+BOOL GetAdapterMode(LPCSTR lpszDeviceName, D3DDISPLAYMODE* pMode)
+{
+ DEVMODEA DevMode;
+
+ memset(&DevMode, 0, sizeof(DEVMODEA));
+ DevMode.dmSize = sizeof(DEVMODEA);
+ if (FALSE == EnumDisplaySettingsA(lpszDeviceName, ENUM_CURRENT_SETTINGS,
&DevMode))
+ return FALSE;
+
+ pMode->Width = DevMode.dmPelsWidth;
+ pMode->Height = DevMode.dmPelsHeight;
+ pMode->RefreshRate = DevMode.dmDisplayFrequency;
+
+ switch (DevMode.dmBitsPerPel)
+ {
+ case 8:
+ pMode->Format = D3DFMT_P8;
+ break;
+
+ case 16:
+ pMode->Format = Get16BitD3DFormat(lpszDeviceName);
+ break;
+
+ case 24:
+ pMode->Format = D3DFMT_R8G8B8;
+ break;
+
+ case 32:
+ pMode->Format = D3DFMT_X8R8G8B8;
+ break;
+
+ default:
+ pMode->Format = D3DFMT_UNKNOWN;
+ break;
+ }
+
+ return TRUE;
+}
+
+
+
static BOOL CALLBACK AdapterMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT
lprcMonitor, LPARAM dwData)
{
MONITORINFOEXA MonitorInfoEx;
Modified: trunk/reactos/dll/directx/d3d9/adapter.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/adapter.h…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/adapter.h (original)
+++ trunk/reactos/dll/directx/d3d9/adapter.h Tue Feb 12 20:30:32 2008
@@ -11,6 +11,8 @@
BOOL GetAdapterInfo(LPCSTR lpszDeviceName, D3DADAPTER_IDENTIFIER9* pIdentifier);
+BOOL GetAdapterMode(LPCSTR lpszDeviceName, D3DDISPLAYMODE* pMode);
+
HMONITOR GetAdapterMonitor(LPCSTR lpszDeviceName);
UINT GetDisplayFormatCount(D3DFORMAT Format, const D3DDISPLAYMODE*
pSupportedDisplayModes, UINT NumDisplayModes);
Modified: trunk/reactos/dll/directx/d3d9/d3d9_impl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_impl…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_impl.c (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_impl.c Tue Feb 12 20:30:32 2008
@@ -291,10 +291,51 @@
return D3D_OK;
}
-static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT
Adapter, D3DDISPLAYMODE* pMode)
-{
- UNIMPLEMENTED
-
+/*++
+* @name IDirect3D9::GetAdapterDisplayMode
+* @implemented
+*
+* The function IDirect3D9Impl_GetAdapterDisplayMode fills the pMode argument with the
+* currently set display mode.
+*
+* @param LPDIRECT3D iface
+* Pointer to the IDirect3D object returned from Direct3DCreate9()
+*
+* @param UINT Adapter
+* Adapter index to get information about. D3DADAPTER_DEFAULT is the primary display.
+* The maximum value for this is the value returned by IDirect3D::GetAdapterCount().
+*
+* @param D3DDISPLAYMODE* pMode
+* Pointer to a D3DDISPLAYMODE structure to be filled with the current display mode
information.
+*
+* @return HRESULT
+* If the method successfully fills the pMode structure, the return value is D3D_OK.
+* If Adapter is out of range or pMode is a bad pointer, the return value will be
D3DERR_INVALIDCALL.
+*
+*/static HRESULT WINAPI IDirect3D9Impl_GetAdapterDisplayMode(LPDIRECT3D9 iface, UINT
Adapter, D3DDISPLAYMODE* pMode)
+{
+ LPDIRECT3D9_INT This = impl_from_IDirect3D9(iface);
+ LOCK_D3D9();
+
+ if (Adapter >= This->NumDisplayAdapters)
+ {
+ DPRINT1("Invalid Adapter number specified");
+ UNLOCK_D3D9();
+ return D3DERR_INVALIDCALL;
+ }
+
+ if (IsBadWritePtr(pMode, sizeof(D3DDISPLAYMODE)))
+ {
+ DPRINT1("Invalid pMode parameter specified");
+ UNLOCK_D3D9();
+ return D3DERR_INVALIDCALL;
+ }
+
+ /* TODO: Handle (This->DisplayAdapters[Adapter].bInUseFlag == FALSE) */
+ if (FALSE == GetAdapterMode(This->DisplayAdapters[Adapter].szDeviceName, pMode))
+ DPRINT1("Internal error, GetAdapterMode() failed.");
+
+ UNLOCK_D3D9();
return D3D_OK;
}
Modified: trunk/reactos/dll/directx/d3d9/d3d9_private.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/d3d9/d3d9_priv…
==============================================================================
--- trunk/reactos/dll/directx/d3d9/d3d9_private.h (original)
+++ trunk/reactos/dll/directx/d3d9/d3d9_private.h Tue Feb 12 20:30:32 2008
@@ -102,11 +102,11 @@
/* 0x0260 */ DWORD unknown000083;
/* 0x0264 */ DWORD unknown000084;
/* 0x0268 */ DWORD unknown000085;
-/* 0x026c */ DWORD dwDisplayWidth; /* Current display res */
-/* 0x0270 */ DWORD dwDisplayHeight; /* Current display res */
-/* 0x0274 */ DWORD unknown000088;
-/* 0x0278 */ DWORD unknown000089;
-/* 0x027c */ DWORD unknown000090;
+/* 0x026c */ DWORD dwDisplayWidth; /* Current display res */
+/* 0x0270 */ DWORD dwDisplayHeight; /* Current display res */
+/* 0x0274 */ DWORD unknown000088; /* Current D3DFORMAT */
+/* 0x0278 */ DWORD unknown000089; /* Current D3DFORMAT - duplicate? */
+/* 0x027c */ DWORD MonitorFrequency; /* Current monitor frequency */
/* 0x0280 */ DWORD unknown000091;
/* 0x0284 */ DWORD unknown000092;
/* 0x0288 */ DWORD unknown000093;