diff --git a/reactos/dll/directx/d3d9/d3d9.rbuild b/reactos/dll/directx/d3d9/d3d9.rbuild
index 913f0742f19..c6693b1ae26 100644
--- a/reactos/dll/directx/d3d9/d3d9.rbuild
+++ b/reactos/dll/directx/d3d9/d3d9.rbuild
@@ -13,15 +13,16 @@
d3d8thk
d3d9.c
+ d3d9_baseobject.c
+ d3d9_caps.c
+ d3d9_create.c
+ d3d9_cursor.c
+ d3d9_device.c
+ d3d9_haldevice.c
d3d9_helpers.c
d3d9_impl.c
- d3d9_baseobject.c
- d3d9_create.c
- d3d9_caps.c
- d3d9_device.c
- d3d9_swapchain.c
d3d9_puredevice.c
- d3d9_haldevice.c
+ d3d9_swapchain.c
adapter.c
device.c
format.c
diff --git a/reactos/dll/directx/d3d9/d3d9_baseobject.c b/reactos/dll/directx/d3d9/d3d9_baseobject.c
index aef859673df..41a7681316a 100644
--- a/reactos/dll/directx/d3d9/d3d9_baseobject.c
+++ b/reactos/dll/directx/d3d9/d3d9_baseobject.c
@@ -71,3 +71,18 @@ HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9**
return E_NOINTERFACE;
}
+
+HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, DIRECT3DDEVICE9_INT** ppDevice)
+{
+ if (pBaseObject->pUnknown)
+ {
+ LPDIRECT3DDEVICE9 pDevice;
+ if (FAILED(pBaseObject->pUnknown->lpVtbl->QueryInterface((IUnknown*) &pBaseObject->pUnknown->lpVtbl, &IID_IDirect3DDevice9, (void**)&pDevice)))
+ return E_NOINTERFACE;
+
+ *ppDevice = IDirect3DDevice9ToImpl(pDevice);
+ return D3D_OK;
+ }
+
+ return E_NOINTERFACE;
+}
diff --git a/reactos/dll/directx/d3d9/d3d9_baseobject.h b/reactos/dll/directx/d3d9/d3d9_baseobject.h
index 73bfbab06b3..33a8f9e1a3d 100644
--- a/reactos/dll/directx/d3d9/d3d9_baseobject.h
+++ b/reactos/dll/directx/d3d9/d3d9_baseobject.h
@@ -12,6 +12,7 @@
#include
struct _D3D9BaseObject;
+struct _Direct3DDevice9_INT;
enum REF_TYPE
{
@@ -42,5 +43,6 @@ VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, IUnk
ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject);
ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject);
HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9** ppDevice);
+HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, struct _Direct3DDevice9_INT** ppDevice);
#endif // _D3D9_BASEOBJECT_H_
diff --git a/reactos/dll/directx/d3d9/d3d9_cursor.c b/reactos/dll/directx/d3d9/d3d9_cursor.c
new file mode 100644
index 00000000000..477eeb7775f
--- /dev/null
+++ b/reactos/dll/directx/d3d9/d3d9_cursor.c
@@ -0,0 +1,34 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS ReactX
+ * FILE: dll/directx/d3d9/d3d9_cursor.h
+ * PURPOSE: d3d9.dll internal cursor methods
+ * PROGRAMERS: Gregor Gullwi
+ */
+#include "d3d9_cursor.h"
+
+#include
+#include
+#include "d3d9_private.h"
+#include "adapter.h"
+#include "d3d9_device.h"
+#include "d3d9_swapchain.h"
+#include "d3d9_helpers.h"
+
+D3D9Cursor* CreateD3D9Cursor(struct _Direct3DDevice9_INT* pBaseDevice, struct _Direct3DSwapChain9_INT* pSwapChain)
+{
+ D3D9Cursor* pCursor;
+
+ if (FAILED(AlignedAlloc((LPVOID*)&pCursor, sizeof(D3D9Cursor))))
+ {
+ DPRINT1("Failed to allocate D3D9Cursor");
+ return NULL;
+ }
+
+ pCursor->pBaseDevice = pBaseDevice;
+ pCursor->pSwapChain = pSwapChain;
+ pCursor->dwWidth = pSwapChain->dwWidth / 2;
+ pCursor->dwHeight = pSwapChain->dwHeight / 2;
+
+ return pCursor;
+}
diff --git a/reactos/dll/directx/d3d9/d3d9_cursor.h b/reactos/dll/directx/d3d9/d3d9_cursor.h
new file mode 100644
index 00000000000..a43280d3d47
--- /dev/null
+++ b/reactos/dll/directx/d3d9/d3d9_cursor.h
@@ -0,0 +1,34 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS ReactX
+ * FILE: dll/directx/d3d9/d3d9_cursor.h
+ * PURPOSE: d3d9.dll internal cursor methods
+ * PROGRAMERS: Gregor Gullwi
+ */
+#ifndef _D3D9_CURSOR_H
+#define _D3D9_CURSOR_H
+
+#include "d3d9_common.h"
+
+typedef struct _D3D9Cursor
+{
+/* 0x0000 */ DWORD dwUnknown0000;
+/* 0x0004 */ DWORD dwUnknown0004;
+/* 0x0008 */ DWORD dwUnknown0008;
+/* 0x000c */ DWORD dwUnknown000c;
+/* 0x0010 */ DWORD dwUnknown0010;
+/* 0x0014 */ DWORD dwUnknown0014;
+/* 0x0018 */ DWORD dwWidth;
+/* 0x001c */ DWORD dwHeight;
+/* 0x0020 */ DWORD dwUnknown0020[18];
+/* 0x0070 */ struct _Direct3DDevice9_INT* pBaseDevice;
+/* 0x0074 */ struct _Direct3DSwapChain9_INT* pSwapChain;
+/* 0x0078 */ DWORD dwUnknown0078;
+/* 0x007c */ DWORD dwMonitorVirtualX;
+/* 0x0080 */ DWORD dwMonitorVirtualY;
+/* 0x0084 */ DWORD dwUnknown0084;
+} D3D9Cursor;
+
+D3D9Cursor* CreateD3D9Cursor(struct _Direct3DDevice9_INT* pBaseDevice, struct _Direct3DSwapChain9_INT* pSwapChain);
+
+#endif // _D3D9_CURSOR_H
diff --git a/reactos/dll/directx/d3d9/d3d9_device.c b/reactos/dll/directx/d3d9/d3d9_device.c
index c763724ce0a..1023040fefb 100644
--- a/reactos/dll/directx/d3d9/d3d9_device.c
+++ b/reactos/dll/directx/d3d9/d3d9_device.c
@@ -15,7 +15,7 @@
#define UNLOCK_D3DDEVICE9() if (This->bLockDevice) LeaveCriticalSection(&This->CriticalSection);
/* Convert a IDirect3D9 pointer safely to the internal implementation struct */
-static LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
+LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
{
if (NULL == iface)
return NULL;
@@ -63,6 +63,7 @@ ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface)
{
DestroyD3D9DeviceData(&This->DeviceData[iAdapter]);
}
+ This->lpVtbl->VirtualDestructor(iface);
LeaveCriticalSection(&This->CriticalSection);
AlignedFree(This);
@@ -71,7 +72,7 @@ ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface)
return ref;
}
-/* IDirect3D9Device interface */
+/* IDirect3DDevice9 public interface */
HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface)
{
UNIMPLEMENTED
@@ -544,3 +545,14 @@ HRESULT WINAPI IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE
return D3D_OK;
}
+
+/* IDirect3DDevice9 private interface */
+VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface)
+{
+ UNIMPLEMENTED
+}
+
+VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface)
+{
+ UNIMPLEMENTED
+}
diff --git a/reactos/dll/directx/d3d9/d3d9_device.h b/reactos/dll/directx/d3d9/d3d9_device.h
index 2eca346cab9..37cf71f8f7b 100644
--- a/reactos/dll/directx/d3d9/d3d9_device.h
+++ b/reactos/dll/directx/d3d9/d3d9_device.h
@@ -83,25 +83,6 @@ typedef struct _D3D9ResourceManager
/* 0x0014 - 0x0174 */ D3D9HeapTexture* pTextureHeap;
} D3D9ResourceManager;
-typedef struct _D3D9Cursor
-{
-/* 0x0000 */ DWORD dwUnknown0000;
-/* 0x0004 */ DWORD dwUnknown0004;
-/* 0x0008 */ DWORD dwUnknown0008;
-/* 0x000c */ DWORD dwUnknown000c;
-/* 0x0010 */ DWORD dwUnknown0010;
-/* 0x0014 */ DWORD dwUnknown0014;
-/* 0x0018 */ DWORD dwWidth;
-/* 0x001c */ DWORD dwHeight;
-/* 0x0020 */ DWORD dwUnknown0020[18];
-/* 0x0070 */ struct _Direct3DDevice9_INT* pBaseDevice;
-/* 0x0074 */ struct _Direct3DSwapChain9_INT* pSwapChain;
-/* 0x0078 */ DWORD dwUnknown0078;
-/* 0x007c */ DWORD dwMonitorVirtualX;
-/* 0x0080 */ DWORD dwMonitorVirtualY;
-/* 0x0084 */ DWORD dwUnknown0084;
-} D3D9Cursor;
-
typedef struct _Direct3DDevice9_INT
{
/* 0x0000 */ struct _IDirect3DDevice9Vtbl_INT* lpVtbl;
@@ -204,12 +185,15 @@ typedef struct _Direct3DDevice9_INT
/* 0x1f44 */ DWORD unknown002001;
} DIRECT3DDEVICE9_INT, FAR* LPDIRECT3DDEVICE9_INT;
+/* Helper functions */
+LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface);
+
/* IUnknown interface */
HRESULT WINAPI IDirect3DDevice9Base_QueryInterface(LPDIRECT3DDEVICE9 iface, REFIID riid, void** ppvObject);
ULONG WINAPI IDirect3DDevice9Base_AddRef(LPDIRECT3DDEVICE9 iface);
ULONG WINAPI IDirect3DDevice9Base_Release(LPDIRECT3DDEVICE9 iface);
-/* IDirect3D9Device public interface */
+/* IDirect3DDevice9 public interface */
HRESULT WINAPI IDirect3DDevice9Base_TestCooperativeLevel(LPDIRECT3DDEVICE9 iface);
UINT WINAPI IDirect3DDevice9Base_GetAvailableTextureMem(LPDIRECT3DDEVICE9 iface);
HRESULT WINAPI IDirect3DDevice9Base_EvictManagedResources(LPDIRECT3DDEVICE9 iface);
@@ -245,4 +229,8 @@ HRESULT WINAPI IDirect3DDevice9Base_StretchRect(LPDIRECT3DDEVICE9 iface, IDirect
HRESULT WINAPI IDirect3DDevice9Base_ColorFill(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pSurface, CONST RECT* pRect, D3DCOLOR color);
HRESULT WINAPI IDirect3DDevice9Base_CreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 iface, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle);
+/* IDirect3DDevice9 private interface */
+VOID WINAPI IDirect3DDevice9Base_Destroy(LPDIRECT3DDEVICE9 iface);
+VOID WINAPI IDirect3DDevice9Base_VirtualDestructor(LPDIRECT3DDEVICE9 iface);
+
#endif /* _D3D9_DEVICE_H_ */
diff --git a/reactos/dll/directx/d3d9/d3d9_swapchain.c b/reactos/dll/directx/d3d9/d3d9_swapchain.c
index 72d5cdddd66..28011da1354 100644
--- a/reactos/dll/directx/d3d9/d3d9_swapchain.c
+++ b/reactos/dll/directx/d3d9/d3d9_swapchain.c
@@ -12,6 +12,7 @@
#include "d3d9_helpers.h"
#include "d3d9_device.h"
+#include "d3d9_cursor.h"
#define LOCK_D3DDEVICE9() if (This->BaseObject.pUnknown && ((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->bLockDevice) \
EnterCriticalSection(&((LPDIRECT3DDEVICE9_INT)This->BaseObject.pUnknown)->CriticalSection);
@@ -184,7 +185,7 @@ static IDirect3DSwapChain9Vtbl Direct3DSwapChain9_Vtbl =
Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _Direct3DDevice9_INT* pBaseDevice, DWORD ChainIndex)
{
Direct3DSwapChain9_INT* pThisSwapChain;
- if (FAILED(AlignedAlloc((LPVOID *)&pThisSwapChain, sizeof(Direct3DSwapChain9_INT))))
+ if (FAILED(AlignedAlloc((LPVOID*)&pThisSwapChain, sizeof(Direct3DSwapChain9_INT))))
{
DPRINT1("Could not create Direct3DSwapChain9_INT");
return NULL;
@@ -202,15 +203,16 @@ Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _
return pThisSwapChain;
}
-VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DDISPLAYMODE* pMode)
+VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
- pThisSwapChain->dwWidth = pMode->Width;
- pThisSwapChain->dwHeight = pMode->Height;
+ pThisSwapChain->dwWidth = pPresentationParameters->BackBufferWidth;
+ pThisSwapChain->dwHeight = pPresentationParameters->BackBufferHeight;
}
HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
int i;
+ DIRECT3DDEVICE9_INT* pDevice;
for (i = 0; i < 256; i++)
{
@@ -221,6 +223,20 @@ HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESE
pThisSwapChain->PresentParameters = pPresentationParameters[pThisSwapChain->ChainIndex];
pThisSwapChain->SwapEffect = pPresentationParameters->SwapEffect;
+ Direct3DSwapChain9_SetDisplayMode(pThisSwapChain, &pThisSwapChain->PresentParameters);
+
+ if (FAILED(D3D9BaseObject_GetDeviceInt(&pThisSwapChain->BaseObject, &pDevice)))
+ {
+ DPRINT1("Could not get the swapchain device");
+ return DDERR_GENERIC;
+ }
+
+ pThisSwapChain->pCursor = CreateD3D9Cursor(pDevice, pThisSwapChain);
+ if (NULL == pThisSwapChain->pCursor)
+ {
+ DPRINT1("Could not allocate D3D9Cursor");
+ return DDERR_OUTOFMEMORY;
+ }
return Direct3DSwapChain9_Reset(pThisSwapChain, pPresentationParameters);
}
diff --git a/reactos/dll/directx/d3d9/d3d9_swapchain.h b/reactos/dll/directx/d3d9/d3d9_swapchain.h
index 4a2de2210c8..c6e76095fdc 100644
--- a/reactos/dll/directx/d3d9/d3d9_swapchain.h
+++ b/reactos/dll/directx/d3d9/d3d9_swapchain.h
@@ -74,7 +74,7 @@ typedef struct _Direct3DSwapChain9_INT
Direct3DSwapChain9_INT* CreateDirect3DSwapChain9(enum REF_TYPE RefType, struct _Direct3DDevice9_INT* pBaseDevice, DWORD ChainIndex);
-VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DDISPLAYMODE* pMode);
+VOID Direct3DSwapChain9_SetDisplayMode(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters);
HRESULT Direct3DSwapChain9_Init(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters);
HRESULT Direct3DSwapChain9_Reset(Direct3DSwapChain9_INT* pThisSwapChain, D3DPRESENT_PARAMETERS* pPresentationParameters);
diff --git a/reactos/dll/directx/d3d9/device.c b/reactos/dll/directx/d3d9/device.c
index bddd3805732..049d3074e95 100644
--- a/reactos/dll/directx/d3d9/device.c
+++ b/reactos/dll/directx/d3d9/device.c
@@ -81,7 +81,6 @@ HRESULT InitD3D9BaseDevice(LPDIRECT3DDEVICE9_INT pThisBaseDevice, LPDIRECT3D9_IN
pThisBaseDevice->pSwapChains[i] = CreateDirect3DSwapChain9(RT_BUILTIN, pThisBaseDevice, i);
pThisBaseDevice->pSwapChains2[i] = pThisBaseDevice->pSwapChains[i];
- Direct3DSwapChain9_SetDisplayMode(pThisBaseDevice->pSwapChains[i], &pThisBaseDevice->CurrentDisplayMode[i]);
if (FAILED(Direct3DSwapChain9_Init(pThisBaseDevice->pSwapChains[i], pPresentationParameters)))
{