Implemented IDirect3D9->QueryInterface()
authorGregor Brunmar <gbrunmar.ros@gmail.com>
Wed, 19 Dec 2007 19:49:10 +0000 (19:49 +0000)
committerGregor Brunmar <gbrunmar.ros@gmail.com>
Wed, 19 Dec 2007 19:49:10 +0000 (19:49 +0000)
svn path=/trunk/; revision=31332

reactos/dll/directx/d3d9/d3d9.c
reactos/dll/directx/d3d9/d3d9.rbuild
reactos/dll/directx/d3d9/d3d9_helpers.c
reactos/dll/directx/d3d9/d3d9_helpers.h
reactos/dll/directx/d3d9/d3d9_impl.c
reactos/dll/directx/d3d9/d3d9_private.h

index 58e93e5..64e3f27 100644 (file)
@@ -61,6 +61,7 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
     LPDIRECT3D9 D3D9Obj = 0;
     LPDIRECT3DCREATE9 DebugDirect3DCreate9 = 0;
     CHAR DebugMessageBuffer[DEBUG_MESSAGE_BUFFER_SIZE];
+    UINT NoDebugSDKVersion = SDKVersion & 0x7FFFFFFF;
 
     UNIMPLEMENTED
 
@@ -80,11 +81,11 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
         }
     }
 
-    if ((SDKVersion & 0x7FFFFFFF) != D3D_SDK_VERSION || (SDKVersion & 0x7FFFFFFF) != D3D9b_SDK_VERSION)
+    if (NoDebugSDKVersion != D3D_SDK_VERSION && NoDebugSDKVersion != D3D9b_SDK_VERSION)
     {
         if (SDKVersion & 0x80000000)
         {
-            FormatDebugString(DebugMessageBuffer, DEBUG_MESSAGE_BUFFER_SIZE, D3dError_WrongSdkVersion, SDKVersion, D3D_SDK_VERSION);
+            FormatDebugString(DebugMessageBuffer, DEBUG_MESSAGE_BUFFER_SIZE, D3dError_WrongSdkVersion, NoDebugSDKVersion, D3D_SDK_VERSION);
             OutputDebugStringA(DebugMessageBuffer);
         }
 
@@ -98,13 +99,13 @@ IDirect3D9* WINAPI Direct3DCreate9(UINT SDKVersion)
 
 BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
 {
-       switch (ul_reason_for_call)
-       {
-               case DLL_PROCESS_ATTACH:
-               case DLL_THREAD_ATTACH:
-               case DLL_THREAD_DETACH:
-               case DLL_PROCESS_DETACH:
-                       break;
+    switch (ul_reason_for_call)
+    {
+        case DLL_PROCESS_ATTACH:
+        case DLL_THREAD_ATTACH:
+        case DLL_THREAD_DETACH:
+        case DLL_PROCESS_DETACH:
+            break;
     }
 
     return TRUE;
index a456871..90b374d 100644 (file)
@@ -5,6 +5,8 @@
 \r
        <library>advapi32</library>\r
        <library>kernel32</library>\r
+       <library>uuid</library>\r
+       <library>dxguid</library>\r
 \r
        <file>d3d9.c</file>\r
        <file>d3d9_helpers.c</file>\r
index 146eb19..b80ccc9 100644 (file)
@@ -56,7 +56,7 @@ HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR For
     return 0;
 }
 
-HRESULT CreateD3D9(IDirect3D9** ppDirect3D9)
+HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9)
 {
     LPDIRECTD3D9_INT pDirect3D9;
 
@@ -71,9 +71,9 @@ HRESULT CreateD3D9(IDirect3D9** ppDirect3D9)
     pDirect3D9->unknown000007 = 0;
     pDirect3D9->lpInt = 0;
 
-    //pDirect3D9->lpVtbl = &IDirect3D3_Vtbl;
+    pDirect3D9->lpVtbl = &Direct3D9_Vtbl;
     pDirect3D9->dwProcessId = GetCurrentThreadId();
-    pDirect3D9->dwIntRefCnt = 1;
+    pDirect3D9->dwRefCnt = 1;
 
     *ppDirect3D9 = (IDirect3D9*)pDirect3D9;
 
index c2a038d..90ae464 100644 (file)
@@ -16,4 +16,4 @@ BOOL ReadRegistryValue(IN DWORD ValueType, IN LPCSTR ValueName, OUT LPBYTE DataB
 HRESULT FormatDebugString(IN OUT LPSTR Buffer, IN LONG BufferSize, IN LPCSTR FormatString, ... );
 
 /* Creates a Direct3D9 object */
-HRESULT CreateD3D9(IDirect3D9** ppDirect3D9);
+HRESULT CreateD3D9(OUT LPDIRECT3D9 *ppDirect3D9);
index b15d196..629e4b6 100644 (file)
@@ -9,10 +9,17 @@
 
 #include <debug.h>
 
+static ULONG WINAPI IDirect3D9Impl_AddRef(LPDIRECT3D9 iface);
+
 /* IDirect3D9: IUnknown implementation */
-static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppobj)
+static HRESULT WINAPI IDirect3D9Impl_QueryInterface(LPDIRECT3D9 iface, REFIID riid, LPVOID* ppvObject)
 {
-    UNIMPLEMENTED
+    if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDirect3D9))
+    {
+        IDirect3D9Impl_AddRef(iface);
+        *ppvObject = iface;
+        return S_OK;
+    }
 
     return E_NOINTERFACE;
 }
@@ -146,7 +153,7 @@ static HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT
 static HRESULT WINAPI IDirect3D9Impl_CreateDevice(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType,
                                                   HWND hFocusWindow, DWORD BehaviourFlags,
                                                   D3DPRESENT_PARAMETERS* pPresentationParameters,
-                                                  IDirect3DDevice9** ppReturnedDeviceInterface)
+                                                  struct IDirect3DDevice9** ppReturnedDeviceInterface)
 {
     UNIMPLEMENTED
 
index 24789de..316bef7 100644 (file)
 
 typedef IDirect3D9* (WINAPI *LPDIRECT3DCREATE9)(UINT);
 
+extern const IDirect3D9Vtbl Direct3D9_Vtbl;
+
 typedef struct _tagDIRECTD3D9_INT_
 {
-/* 0x0000 */    LPVOID lpVtbl; /* LPDIRECTD3D9 functoions table */
+/* 0x0000 */    const IDirect3D9Vtbl *lpVtbl; /* LPDIRECTD3D9 functoions table */
 /* 0x0004 */    CRITICAL_SECTION d3d9_cs;
-/* 0x001c */    DWORD unknown000007;  /* 0x00000001 */
+/* 0x001c */    DWORD unknown000007;    /* 0x00000001 */
 /* 0x0020 */    DWORD dwProcessId; 
 /* 0x0024 */    struct _tagDIRECTD3D9_INT_ * lpInt; 
-/* 0x0028 */    volatile LONG dwRefCnt; /* Increases and decreases by AddRef() and Release() */
+/* 0x0028 */    LONG dwRefCnt;          /* Increases and decreases by AddRef() and Release() */
 /* 0x002c */    DWORD unknown000011;    /* 0x00000001 - Probably AdapterIndex */
 /* 0x0030 */    GUID DisplayGuid;       /*? Always {67685559-3106-11D0-B971-00AA00342F9F} ? */
 /* 0x0040 */    CHAR DeviceName[16];