- some cleanups and fixes on d3d8 and d3d9 headers
[wine/multimedia.git] / dlls / d3d9 / vertexbuffer.c
blob849690690b581a21c643192388929d430670ff0e
1 /*
2 * IDirect3DResource9 implementation
4 * Copyright 2002-2003 Jason Edmeades
5 * Raphael Junqueira
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "wingdi.h"
30 #include "wine/debug.h"
32 #include "d3d9_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
36 /* IDirect3DVertexBuffer9 IUnknown parts follow: */
37 HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
38 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDirect3DResource9)
42 || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
43 IDirect3DVertexBuffer9Impl_AddRef(iface);
44 *ppobj = This;
45 return D3D_OK;
48 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
49 return E_NOINTERFACE;
52 ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
53 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
54 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
55 return ++(This->ref);
58 ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
59 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
60 ULONG ref = --This->ref;
61 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
62 if (ref == 0) {
63 if (NULL != This->allocatedMemory) HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
64 HeapFree(GetProcessHeap(), 0, This);
66 return ref;
69 /* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
70 HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
71 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
72 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
75 HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
76 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
77 FIXME("(%p) : stub\n", This);
78 return D3D_OK;
81 HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
82 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
83 FIXME("(%p) : stub\n", This);
84 return D3D_OK;
87 HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
88 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
89 FIXME("(%p) : stub\n", This);
90 return D3D_OK;
93 DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
94 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
95 return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9) This, PriorityNew);
98 DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
99 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
100 return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9) This);
103 void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
104 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
105 FIXME("(%p) : stub\n", This);
106 return ;
109 D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
110 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
111 return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9) This);
114 /* IDirect3DVertexBuffer9 Interface follow: */
115 HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
116 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
117 FIXME("(%p) : stub\n", This);
118 return D3D_OK;
121 HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
122 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
123 FIXME("(%p) : stub\n", This);
124 return D3D_OK;
127 HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
128 ICOM_THIS(IDirect3DVertexBuffer9Impl,iface);
129 TRACE("(%p) : copying into %p\n", This, pDesc);
130 memcpy(pDesc, &This->myDesc, sizeof(D3DVERTEXBUFFER_DESC));
131 return D3D_OK;
135 ICOM_VTABLE(IDirect3DVertexBuffer9) Direct3DVertexBuffer9_Vtbl =
137 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
138 IDirect3DVertexBuffer9Impl_QueryInterface,
139 IDirect3DVertexBuffer9Impl_AddRef,
140 IDirect3DVertexBuffer9Impl_Release,
141 IDirect3DVertexBuffer9Impl_GetDevice,
142 IDirect3DVertexBuffer9Impl_SetPrivateData,
143 IDirect3DVertexBuffer9Impl_GetPrivateData,
144 IDirect3DVertexBuffer9Impl_FreePrivateData,
145 IDirect3DVertexBuffer9Impl_SetPriority,
146 IDirect3DVertexBuffer9Impl_GetPriority,
147 IDirect3DVertexBuffer9Impl_PreLoad,
148 IDirect3DVertexBuffer9Impl_GetType,
149 IDirect3DVertexBuffer9Impl_Lock,
150 IDirect3DVertexBuffer9Impl_Unlock,
151 IDirect3DVertexBuffer9Impl_GetDesc
155 /* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
156 HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface,
157 UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
158 IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
159 IDirect3DVertexBuffer9Impl *object;
161 ICOM_THIS(IDirect3DDevice9Impl,iface);
163 /* Allocate the storage for the device */
164 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
165 object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
166 object->ref = 1;
167 object->Device = This;
169 object->ResourceType = D3DRTYPE_VERTEXBUFFER;
171 object->allocatedMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size);
172 object->myDesc.Usage = Usage;
173 object->myDesc.Pool = Pool;
174 object->myDesc.FVF = FVF;
175 object->myDesc.Size = Size;
177 TRACE("(%p) : Size=%d, Usage=%ld, FVF=%lx, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->allocatedMemory, object);
179 *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
181 return D3D_OK;