2 * IDirect3DVertexBuffer9 implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2002-2004 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "d3d9_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
28 /* IDirect3DVertexBuffer9 IUnknown parts follow: */
29 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
30 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
32 if (IsEqualGUID(riid, &IID_IUnknown)
33 || IsEqualGUID(riid, &IID_IDirect3DResource9)
34 || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
35 IUnknown_AddRef(iface);
40 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
45 static ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
46 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
47 ULONG ref = InterlockedIncrement(&This->ref);
49 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
54 static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
55 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
56 ULONG ref = InterlockedDecrement(&This->ref);
58 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
61 IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
62 IUnknown_Release(This->parentDevice);
63 HeapFree(GetProcessHeap(), 0, This);
68 /* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
69 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
70 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
71 TRACE("(%p) Relay\n", This);
72 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
75 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
76 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
77 TRACE("(%p) Relay\n", This);
78 return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
81 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
82 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
83 TRACE("(%p) Relay\n", This);
84 return IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
87 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
88 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
89 TRACE("(%p) Relay\n", This);
90 return IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
93 static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
94 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
95 TRACE("(%p) Relay\n", This);
96 return IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
99 static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
100 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
101 TRACE("(%p) Relay\n", This);
102 return IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
105 static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
106 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
107 TRACE("(%p) Relay\n", This);
108 IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
112 static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
113 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
114 TRACE("(%p) Relay\n", This);
115 return IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
118 /* IDirect3DVertexBuffer9 Interface follow: */
119 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
120 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
121 TRACE("(%p) Relay\n", This);
122 return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
125 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
126 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
127 TRACE("(%p) Relay\n", This);
128 return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
131 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
132 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
133 TRACE("(%p) Relay\n", This);
134 return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
137 static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
140 IDirect3DVertexBuffer9Impl_QueryInterface,
141 IDirect3DVertexBuffer9Impl_AddRef,
142 IDirect3DVertexBuffer9Impl_Release,
143 /* IDirect3DResource9 */
144 IDirect3DVertexBuffer9Impl_GetDevice,
145 IDirect3DVertexBuffer9Impl_SetPrivateData,
146 IDirect3DVertexBuffer9Impl_GetPrivateData,
147 IDirect3DVertexBuffer9Impl_FreePrivateData,
148 IDirect3DVertexBuffer9Impl_SetPriority,
149 IDirect3DVertexBuffer9Impl_GetPriority,
150 IDirect3DVertexBuffer9Impl_PreLoad,
151 IDirect3DVertexBuffer9Impl_GetType,
152 /* IDirect3DVertexBuffer9 */
153 IDirect3DVertexBuffer9Impl_Lock,
154 IDirect3DVertexBuffer9Impl_Unlock,
155 IDirect3DVertexBuffer9Impl_GetDesc
159 /* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
160 HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface,
161 UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
162 IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
164 IDirect3DVertexBuffer9Impl *object;
165 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
166 HRESULT hrc = D3D_OK;
168 /* Allocate the storage for the device */
169 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
170 if (NULL == object) {
171 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
172 return D3DERR_OUTOFVIDEOMEMORY;
175 object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
177 hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK, FVF, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
182 FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
183 HeapFree(GetProcessHeap(), 0, object);
185 IUnknown_AddRef(iface);
186 object->parentDevice = iface;
187 TRACE("(%p) : Created vertex buffer %p\n", This, object);
188 *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;