H. Verbeet : d3d8: Add an IDirect3DVertexDeclaration8 class to hold the wined3d vertex declaration .

Alexandre Julliard julliard at wine.codeweavers.com
Wed Feb 14 09:25:44 CST 2007


Module: wine
Branch: master
Commit: a0b417725a1f55589078c9de5194faf5effb3491
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a0b417725a1f55589078c9de5194faf5effb3491

Author: H. Verbeet <hverbeet at gmail.com>
Date:   Tue Feb 13 23:12:19 2007 +0100

d3d8: Add an IDirect3DVertexDeclaration8 class to hold the wined3d vertex declaration.

---

 dlls/d3d8/Makefile.in         |    1 +
 dlls/d3d8/d3d8_private.h      |   32 +++++++++++++++++
 dlls/d3d8/vertexdeclaration.c |   76 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d8/Makefile.in b/dlls/d3d8/Makefile.in
index 87f4812..15bc92a 100644
--- a/dlls/d3d8/Makefile.in
+++ b/dlls/d3d8/Makefile.in
@@ -21,6 +21,7 @@ C_SRCS = \
 	swapchain.c \
 	texture.c \
 	vertexbuffer.c \
+	vertexdeclaration.c \
 	vertexshader.c \
 	volume.c \
 	volumetexture.c
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 0466137..0af3c56 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -437,6 +437,9 @@ struct IDirect3DVolumeTexture8Impl
 DEFINE_GUID(IID_IDirect3DStateBlock8, 
 0x83b073ce, 0x6f30, 0x11d9, 0xc6, 0x87, 0x0, 0x4, 0x61, 0x42, 0xc1, 0x4f);
 
+DEFINE_GUID(IID_IDirect3DVertexDeclaration8,
+0x5dd7478d, 0xcbf3, 0x41a6, 0x8c, 0xfd, 0xfd, 0x19, 0x2b, 0x11, 0xc7, 0x90);
+
 DEFINE_GUID(IID_IDirect3DVertexShader8,
 0xefc5557e, 0x6265, 0x4613, 0x8a, 0x94, 0x43, 0x85, 0x78, 0x89, 0xeb, 0x36);
 
@@ -488,6 +491,35 @@ typedef struct  IDirect3DStateBlock8Impl {
 } IDirect3DStateBlock8Impl;
 
 /*****************************************************************************
+ * IDirect3DVertexDeclaration8 interface
+ */
+#define INTERFACE IDirect3DVertexDeclaration8
+DECLARE_INTERFACE_(IDirect3DVertexDeclaration8, IUnknown)
+{
+    /*** IUnknown methods ***/
+    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** obj_ptr) PURE;
+    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+    STDMETHOD_(ULONG,Release)(THIS) PURE;
+};
+#undef INTERFACE
+
+/*** IUnknown methods ***/
+#define IDirect3DVertexDeclaration8_QueryInterface(p,a,b)  (p)->lpVtbl->QueryInterface(p,a,b)
+#define IDirect3DVertexDeclaration8_AddRef(p)              (p)->lpVtbl->AddRef(p)
+#define IDirect3DVertexDeclaration8_Release(p)             (p)->lpVtbl->Release(p)
+
+/*** Implementation ***/
+extern const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl;
+
+typedef struct {
+    const IDirect3DVertexDeclaration8Vtbl *lpVtbl;
+    LONG ref_count;
+
+    IWineD3DVertexDeclaration *wined3d_vertex_declaration;
+} IDirect3DVertexDeclaration8Impl;
+
+
+/*****************************************************************************
  * IDirect3DVertexShader9 interface
  */
 #define INTERFACE IDirect3DVertexShader8
diff --git a/dlls/d3d8/vertexdeclaration.c b/dlls/d3d8/vertexdeclaration.c
new file mode 100644
index 0000000..8f1e91b
--- /dev/null
+++ b/dlls/d3d8/vertexdeclaration.c
@@ -0,0 +1,76 @@
+/*
+ * IDirect3DVertexDeclaration8 implementation
+ *
+ * Copyright 2007 Henri Verbeet
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/* IDirect3DVertexDeclaration8 is internal to our implementation.
+ * It's not visible in the API. */
+
+#include "config.h"
+#include "d3d8_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
+
+/* IUnknown */
+static HRESULT WINAPI IDirect3DVertexDeclaration8Impl_QueryInterface(IDirect3DVertexDeclaration8 *iface, REFIID riid, void **obj_ptr)
+{
+    TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj_ptr);
+
+    if (IsEqualGUID(riid, &IID_IUnknown)
+            || IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration8))
+    {
+        IUnknown_AddRef(iface);
+        *obj_ptr = iface;
+        return S_OK;
+    }
+
+    *obj_ptr = NULL;
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI IDirect3DVertexDeclaration8Impl_AddRef(IDirect3DVertexDeclaration8 *iface)
+{
+    IDirect3DVertexDeclaration8Impl *This = (IDirect3DVertexDeclaration8Impl *)iface;
+
+    ULONG ref_count = InterlockedIncrement(&This->ref_count);
+    TRACE("(%p) : AddRef increasing to %d\n", This, ref_count);
+
+    return ref_count;
+}
+
+static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDeclaration8 *iface)
+{
+    IDirect3DVertexDeclaration8Impl *This = (IDirect3DVertexDeclaration8Impl *)iface;
+
+    ULONG ref_count = InterlockedDecrement(&This->ref_count);
+    TRACE("(%p) : Releasing to %d\n", This, ref_count);
+
+    if (!ref_count) {
+        IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+
+    return ref_count;
+}
+
+const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl =
+{
+    IDirect3DVertexDeclaration8Impl_QueryInterface,
+    IDirect3DVertexDeclaration8Impl_AddRef,
+    IDirect3DVertexDeclaration8Impl_Release
+};




More information about the wine-cvs mailing list