push b79aff4f9e064e6702329573e5ebb8548e254b61
[wine/hacks.git] / dlls / d3d8 / vertexbuffer.c
blob5dda94f07fa00a5c9e88a926524d8654a6aeb3ce
1 /*
2 * IDirect3DVertexBuffer8 implementation
4 * Copyright 2005 Oliver Stieber
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DVertexBuffer8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
28 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
30 if (IsEqualGUID(riid, &IID_IUnknown)
31 || IsEqualGUID(riid, &IID_IDirect3DResource8)
32 || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) {
33 IUnknown_AddRef(iface);
34 *ppobj = This;
35 return S_OK;
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40 *ppobj = NULL;
41 return E_NOINTERFACE;
44 static ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface) {
45 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
46 ULONG ref = InterlockedIncrement(&This->ref);
48 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
50 return ref;
53 static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
54 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
55 ULONG ref = InterlockedDecrement(&This->ref);
57 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
59 if (ref == 0) {
60 EnterCriticalSection(&d3d8_cs);
61 IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
62 LeaveCriticalSection(&d3d8_cs);
63 IUnknown_Release(This->parentDevice);
64 HeapFree(GetProcessHeap(), 0, This);
67 return ref;
70 /* IDirect3DVertexBuffer8 IDirect3DResource8 Interface follow: */
71 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
72 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
73 HRESULT hr;
74 TRACE("(%p) Relay\n", This);
76 EnterCriticalSection(&d3d8_cs);
77 hr = IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
78 LeaveCriticalSection(&d3d8_cs);
79 return hr;
82 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
83 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
84 HRESULT hr;
85 TRACE("(%p) Relay\n", This);
87 EnterCriticalSection(&d3d8_cs);
88 hr = IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
89 LeaveCriticalSection(&d3d8_cs);
90 return hr;
93 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
94 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
95 HRESULT hr;
96 TRACE("(%p) Relay\n", This);
98 EnterCriticalSection(&d3d8_cs);
99 hr = IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
100 LeaveCriticalSection(&d3d8_cs);
101 return hr;
104 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
105 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
106 HRESULT hr;
107 TRACE("(%p) Relay\n", This);
109 EnterCriticalSection(&d3d8_cs);
110 hr = IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
111 LeaveCriticalSection(&d3d8_cs);
112 return hr;
115 static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
116 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
117 DWORD ret;
118 TRACE("(%p) Relay\n", This);
120 EnterCriticalSection(&d3d8_cs);
121 ret = IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
122 LeaveCriticalSection(&d3d8_cs);
123 return ret;
126 static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
127 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
128 DWORD ret;
129 TRACE("(%p) Relay\n", This);
131 EnterCriticalSection(&d3d8_cs);
132 ret = IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
133 LeaveCriticalSection(&d3d8_cs);
134 return ret;
137 static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
138 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
139 TRACE("(%p) Relay\n", This);
141 EnterCriticalSection(&d3d8_cs);
142 IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
143 LeaveCriticalSection(&d3d8_cs);
146 static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
147 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
148 D3DRESOURCETYPE type;
149 TRACE("(%p) Relay\n", This);
151 EnterCriticalSection(&d3d8_cs);
152 type = IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
153 LeaveCriticalSection(&d3d8_cs);
154 return type;
157 /* IDirect3DVertexBuffer8 Interface follow: */
158 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
159 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
160 HRESULT hr;
161 TRACE("(%p) Relay\n", This);
163 EnterCriticalSection(&d3d8_cs);
164 hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
165 LeaveCriticalSection(&d3d8_cs);
166 return hr;
169 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
170 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
171 HRESULT hr;
172 TRACE("(%p) Relay\n", This);
174 EnterCriticalSection(&d3d8_cs);
175 hr = IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
176 LeaveCriticalSection(&d3d8_cs);
177 return hr;
180 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
181 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
182 HRESULT hr;
183 TRACE("(%p) Relay\n", This);
185 EnterCriticalSection(&d3d8_cs);
186 hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
187 LeaveCriticalSection(&d3d8_cs);
188 return hr;
191 const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
193 /* IUnknown */
194 IDirect3DVertexBuffer8Impl_QueryInterface,
195 IDirect3DVertexBuffer8Impl_AddRef,
196 IDirect3DVertexBuffer8Impl_Release,
197 /* IDirect3DResource8 */
198 IDirect3DVertexBuffer8Impl_GetDevice,
199 IDirect3DVertexBuffer8Impl_SetPrivateData,
200 IDirect3DVertexBuffer8Impl_GetPrivateData,
201 IDirect3DVertexBuffer8Impl_FreePrivateData,
202 IDirect3DVertexBuffer8Impl_SetPriority,
203 IDirect3DVertexBuffer8Impl_GetPriority,
204 IDirect3DVertexBuffer8Impl_PreLoad,
205 IDirect3DVertexBuffer8Impl_GetType,
206 /* IDirect3DVertexBuffer8 */
207 IDirect3DVertexBuffer8Impl_Lock,
208 IDirect3DVertexBuffer8Impl_Unlock,
209 IDirect3DVertexBuffer8Impl_GetDesc