D3D9:
authorGregor Brunmar <gbrunmar.ros@gmail.com>
Tue, 23 Sep 2008 17:01:40 +0000 (17:01 +0000)
committerGregor Brunmar <gbrunmar.ros@gmail.com>
Tue, 23 Sep 2008 17:01:40 +0000 (17:01 +0000)
* More init values when creating a texture

svn path=/trunk/; revision=36429

reactos/dll/directx/d3d9/d3d9.rbuild
reactos/dll/directx/d3d9/d3d9_basetexture.h [new file with mode: 0644]
reactos/dll/directx/d3d9/d3d9_device.c
reactos/dll/directx/d3d9/d3d9_mipmap.c
reactos/dll/directx/d3d9/d3d9_mipmap.h
reactos/dll/directx/d3d9/d3d9_resource.c [new file with mode: 0644]
reactos/dll/directx/d3d9/d3d9_resource.h
reactos/dll/directx/d3d9/d3d9_texture.c [new file with mode: 0644]
reactos/dll/directx/d3d9/d3d9_texture.h

index 8008bcc..c1f0d8a 100644 (file)
@@ -23,7 +23,9 @@
        <file>d3d9_impl.c</file>\r
        <file>d3d9_mipmap.c</file>\r
        <file>d3d9_puredevice.c</file>\r
+       <file>d3d9_resource.c</file>\r
        <file>d3d9_swapchain.c</file>\r
+       <file>d3d9_texture.c</file>\r
        <file>adapter.c</file>\r
        <file>device.c</file>\r
        <file>format.c</file>\r
diff --git a/reactos/dll/directx/d3d9/d3d9_basetexture.h b/reactos/dll/directx/d3d9/d3d9_basetexture.h
new file mode 100644 (file)
index 0000000..5c247a1
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS ReactX
+ * FILE:            dll/directx/d3d9/d3d9_basetexture.h
+ * PURPOSE:         Work-around for gcc warning, DO NOT USE FOR ANYTHING ELSE!!!
+ * PROGRAMERS:      Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
+ */
+#ifndef _D3D9_BASETEXTURE_H_
+#define _D3D9_BASETEXTURE_H_
+
+// Work-around for:
+// "warning: 'FilterType' is narrower than values of its type"
+#if __GNUC__ >=3
+    #pragma GCC system_header
+#endif
+
+struct IDirect3DBaseTexture9Vtbl;
+
+#pragma pack(push)
+#pragma pack(1)
+typedef struct _Direct3DBaseTexture9_INT
+{
+/* 0x0000 */    IDirect3DBaseTexture9Vtbl* lpVtbl;
+/* 0x0004 */    DWORD dwUnknown04;
+/* 0x0008 */    Direct3DResource9_INT BaseResource;
+/* 0x004c */    DWORD dwUnknown4c;
+/* 0x0050 */    D3DFORMAT Format;
+/* 0x0054 */    DWORD Usage;
+/* 0x0058 */    WORD MipMapLevels;
+                union {
+/* 0x005a */        D3DTEXTUREFILTERTYPE FilterType : 8;
+                    struct
+                    {
+/* 0x005a */            DWORD dwFilterType : 8;
+/* 0x005b */            BOOL  bIsAutoGenMipMap : 8;
+/* 0x005c */            DWORD MipMapLevels2 : 16;
+                    };
+                };
+/* 0x005e */    WORD wPaletteIndex;
+} Direct3DBaseTexture9_INT;
+#pragma pack(pop)
+
+#endif
\ No newline at end of file
index a8b6cf6..d34a0a9 100644 (file)
@@ -510,7 +510,7 @@ HRESULT WINAPI IDirect3DDevice9Base_CreateTexture(LPDIRECT3DDEVICE9 iface, UINT
     if (D3DFMT_UNKNOWN == Format)
         return InvalidCall(This, "Invalid Format parameter specified, D3DFMT_UNKNOWN is not a valid Format");
 
-    if (NULL == pSharedHandle)
+    if (NULL != pSharedHandle)
     {
         UNIMPLEMENTED;
         return InvalidCall(This, "Invalid pSharedHandle parameter specified, only NULL is supported at the moment");
index 7d2c2d4..5439eba 100644 (file)
@@ -246,13 +246,16 @@ HRESULT CreateD3D9MipMap(DIRECT3DDEVICE9_INT* pDevice, UINT Width, UINT Height,
         return E_OUTOFMEMORY;
     }
 
+    InitDirect3DBaseTexture9(&pThisTexture->BaseTexture, (IDirect3DBaseTexture9Vtbl*)&D3D9MipMap_Vtbl, Usage, Levels, Format, Pool, pDevice, RT_EXTERNAL);
+
     pThisTexture->lpVtbl = &D3D9MipMap_Vtbl;
     
+    pThisTexture->Usage = Usage;
     pThisTexture->dwWidth = Width;
     pThisTexture->dwHeight = Height;
     pThisTexture->Format = Format;
 
-    *ppTexture = (IDirect3DTexture9*)pThisTexture->lpVtbl;
+    *ppTexture = (IDirect3DTexture9*)&pThisTexture->lpVtbl;
 
     UNIMPLEMENTED;
     return D3D_OK;
index 6242393..c00dfa9 100644 (file)
@@ -19,7 +19,7 @@ typedef struct _D3D9MipMap
 /* 0x0064 */    LPDWORD dwUnknown64;
 /* 0x0068 */    D3DFORMAT Format;
 /* 0x006c */    DWORD dwUnknown6c;
-/* 0x0070 */    DWORD dwUnknown70;
+/* 0x0070 */    DWORD Usage;
 /* 0x0074 */    DWORD dwUnknown74;
 /* 0x0078 */    DWORD dwUnknown78;
 /* 0x007c */    DWORD dwUnknown7c;
diff --git a/reactos/dll/directx/d3d9/d3d9_resource.c b/reactos/dll/directx/d3d9/d3d9_resource.c
new file mode 100644 (file)
index 0000000..092c33a
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS ReactX
+ * FILE:            dll/directx/d3d9/d3d9_resource.c
+ * PURPOSE:         d3d9.dll internal resource functions
+ * PROGRAMERS:      Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
+ */
+#include "d3d9_resource.h"
+#include "d3d9_device.h"
+
+void InitDirect3DResource9(Direct3DResource9_INT* pResource, D3DPOOL Pool, LPDIRECT3DDEVICE9_INT pBaseDevice, enum REF_TYPE RefType)
+{
+    InitD3D9BaseObject(&pResource->BaseObject, RefType, (IUnknown*)&pBaseDevice->lpVtbl);
+
+    pResource->Pool = Pool;
+}
index b38ffa7..c3f2bc1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS ReactX
- * FILE:            dll/directx/d3d9/d3d9_mipmap.h
+ * FILE:            dll/directx/d3d9/d3d9_resource.h
  * PURPOSE:         d3d9.dll internal resource structures
  * PROGRAMERS:      Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
  */
@@ -20,10 +20,10 @@ typedef struct _Direct3DResource9_INT
 /* 0x0030 */    DWORD dwUnknown30;
 /* 0x0034 */    DWORD dwUnknown34;
 /* 0x0038 */    D3DPOOL Pool;
-/* 0x003c */    DWORD dwUnknown3c;
+/* 0x003c */    LPDWORD dwUnknown3c;
 /* 0x0040 */    LPDWORD dwUnknown40;
 } Direct3DResource9_INT;
 
-
+void InitDirect3DResource9(Direct3DResource9_INT* pResource, D3DPOOL Pool, struct _Direct3DDevice9_INT* pDevice, enum REF_TYPE RefType);
 
 #endif // _D3D9_RESOURCE_H_
diff --git a/reactos/dll/directx/d3d9/d3d9_texture.c b/reactos/dll/directx/d3d9/d3d9_texture.c
new file mode 100644 (file)
index 0000000..b24942b
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS ReactX
+ * FILE:            dll/directx/d3d9/d3d9_texture.c
+ * PURPOSE:         d3d9.dll internal texture surface functions
+ * PROGRAMERS:      Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com>
+ */
+#include "d3d9_texture.h"
+
+void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT* pBaseTexture,
+                              IDirect3DBaseTexture9Vtbl* pVtbl,
+                              DWORD Usage,
+                              UINT Levels,
+                              D3DFORMAT Format,
+                              D3DPOOL Pool,
+                              struct _Direct3DDevice9_INT* pDevice,
+                              enum REF_TYPE RefType)
+{
+    InitDirect3DResource9(&pBaseTexture->BaseResource, Pool, pDevice, RefType);
+
+    pBaseTexture->lpVtbl = pVtbl;
+    pBaseTexture->Format = Format;
+    pBaseTexture->wPaletteIndex = 0xFFFF;
+    pBaseTexture->Usage = Usage;
+    pBaseTexture->MipMapLevels =
+        pBaseTexture->MipMapLevels2 = (WORD)Levels;
+
+    pBaseTexture->FilterType = D3DTEXF_LINEAR;
+    pBaseTexture->bIsAutoGenMipMap = (Usage & D3DUSAGE_AUTOGENMIPMAP) != 0;
+}
index 5edecbb..e8f589c 100644 (file)
@@ -9,19 +9,17 @@
 #define _D3D9_TEXTURE_H_
 
 #include "d3d9_resource.h"
+#include "d3d9_basetexture.h"
 
-typedef struct _Direct3DBaseTexture9_INT
-{
-/* 0x0000 */    struct IDirect3DBaseTexture9Vtbl* lpVtbl;
-/* 0x0004 */    DWORD dwUnknown04;
-/* 0x0008 */    Direct3DResource9_INT BaseResource;
-/* 0x004c */    DWORD dwUnknown4c;
-/* 0x0050 */    DWORD dwUnknown50;
-/* 0x0054 */    DWORD Usage;
-/* 0x0058 */    WORD MipMapLevels;
-/* 0x005a */    WORD dUnknown5a;
-/* 0x005c */    WORD MipMapLevels2;
-/* 0x005e */    WORD dUnknown5e;
-} Direct3DBaseTexture9_INT;
+struct IDirect3DBaseTexture9Vtbl;
+
+void InitDirect3DBaseTexture9(Direct3DBaseTexture9_INT* pBaseTexture,
+                              IDirect3DBaseTexture9Vtbl* pVtbl,
+                              DWORD Usage,
+                              UINT Levels,
+                              D3DFORMAT Format,
+                              D3DPOOL Pool,
+                              struct _Direct3DDevice9_INT* pDevice,
+                              enum REF_TYPE RefType);
 
 #endif // _D3D9_TEXTURE_H_