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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "d3d9_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
28 /* IDirect3DVertexBuffer9 IUnknown parts follow: */
29 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);
44 ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
45 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
46 ULONG ref = InterlockedIncrement(&This->ref);
48 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
53 ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
54 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
55 ULONG ref = InterlockedDecrement(&This->ref);
57 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
60 IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
61 HeapFree(GetProcessHeap(), 0, This);
66 /* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
67 HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
68 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
69 TRACE("(%p) Relay\n", This);
70 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
73 HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
74 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
75 TRACE("(%p) Relay\n", This);
76 return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
79 HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
80 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
81 TRACE("(%p) Relay\n", This);
82 return IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
85 HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
86 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
87 TRACE("(%p) Relay\n", This);
88 return IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
91 DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
92 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
93 TRACE("(%p) Relay\n", This);
94 return IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
97 DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
98 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
99 TRACE("(%p) Relay\n", This);
100 return IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
103 void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
104 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
105 TRACE("(%p) Relay\n", This);
106 IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
110 D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
111 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
112 TRACE("(%p) Relay\n", This);
113 return IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
116 /* IDirect3DVertexBuffer9 Interface follow: */
117 HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
118 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
119 TRACE("(%p) Relay\n", This);
120 return IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
123 HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
124 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
125 TRACE("(%p) Relay\n", This);
126 return IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
129 HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
130 IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
131 TRACE("(%p) Relay\n", This);
132 return IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, pDesc);
135 const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
138 IDirect3DVertexBuffer9Impl_QueryInterface,
139 IDirect3DVertexBuffer9Impl_AddRef,
140 IDirect3DVertexBuffer9Impl_Release,
141 /* IDirect3DResource9 */
142 IDirect3DVertexBuffer9Impl_GetDevice,
143 IDirect3DVertexBuffer9Impl_SetPrivateData,
144 IDirect3DVertexBuffer9Impl_GetPrivateData,
145 IDirect3DVertexBuffer9Impl_FreePrivateData,
146 IDirect3DVertexBuffer9Impl_SetPriority,
147 IDirect3DVertexBuffer9Impl_GetPriority,
148 IDirect3DVertexBuffer9Impl_PreLoad,
149 IDirect3DVertexBuffer9Impl_GetType,
150 /* IDirect3DVertexBuffer9 */
151 IDirect3DVertexBuffer9Impl_Lock,
152 IDirect3DVertexBuffer9Impl_Unlock,
153 IDirect3DVertexBuffer9Impl_GetDesc
157 /* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
158 HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9 iface,
159 UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
160 IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
162 IDirect3DVertexBuffer9Impl *object;
163 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
164 HRESULT hrc = D3D_OK;
166 /* Allocate the storage for the device */
167 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
168 if (NULL == object) {
169 FIXME("Allocation of memory failed\n");
170 *ppVertexBuffer = NULL;
171 return D3DERR_OUTOFVIDEOMEMORY;
174 object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
176 hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage, FVF, Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
180 FIXME("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
181 HeapFree(GetProcessHeap(), 0, object);
182 *ppVertexBuffer = NULL;
184 *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;