commdlg: Implemented notifications are only sent with OFN_EXPLORER flag set.
[wine/multimedia.git] / dlls / d3d8 / vertexbuffer.c
bloba282cda6bf286d13fb22a6040d09b21711833dbf
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 IWineD3DBuffer_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 IWineD3DDevice *wined3d_device;
74 HRESULT hr;
75 TRACE("(%p) Relay\n", This);
77 EnterCriticalSection(&d3d8_cs);
78 hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device);
79 if (SUCCEEDED(hr))
81 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
82 IWineD3DDevice_Release(wined3d_device);
84 LeaveCriticalSection(&d3d8_cs);
85 return hr;
88 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
89 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
90 HRESULT hr;
91 TRACE("(%p) Relay\n", This);
93 EnterCriticalSection(&d3d8_cs);
94 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
95 LeaveCriticalSection(&d3d8_cs);
96 return hr;
99 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
100 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
101 HRESULT hr;
102 TRACE("(%p) Relay\n", This);
104 EnterCriticalSection(&d3d8_cs);
105 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
106 LeaveCriticalSection(&d3d8_cs);
107 return hr;
110 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
111 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
112 HRESULT hr;
113 TRACE("(%p) Relay\n", This);
115 EnterCriticalSection(&d3d8_cs);
116 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
117 LeaveCriticalSection(&d3d8_cs);
118 return hr;
121 static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
122 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
123 DWORD ret;
124 TRACE("(%p) Relay\n", This);
126 EnterCriticalSection(&d3d8_cs);
127 ret = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
128 LeaveCriticalSection(&d3d8_cs);
129 return ret;
132 static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
133 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
134 DWORD ret;
135 TRACE("(%p) Relay\n", This);
137 EnterCriticalSection(&d3d8_cs);
138 ret = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
139 LeaveCriticalSection(&d3d8_cs);
140 return ret;
143 static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
144 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
145 TRACE("(%p) Relay\n", This);
147 EnterCriticalSection(&d3d8_cs);
148 IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
149 LeaveCriticalSection(&d3d8_cs);
152 static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
153 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
154 TRACE("(%p)\n", This);
156 return D3DRTYPE_VERTEXBUFFER;
159 /* IDirect3DVertexBuffer8 Interface follow: */
160 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
161 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
162 HRESULT hr;
163 TRACE("(%p) Relay\n", This);
165 EnterCriticalSection(&d3d8_cs);
166 hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
167 LeaveCriticalSection(&d3d8_cs);
168 return hr;
171 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
172 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
173 HRESULT hr;
174 TRACE("(%p) Relay\n", This);
176 EnterCriticalSection(&d3d8_cs);
177 hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
178 LeaveCriticalSection(&d3d8_cs);
179 return hr;
182 static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
183 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
184 HRESULT hr;
185 WINED3DBUFFER_DESC desc;
186 TRACE("(%p) Relay\n", This);
188 EnterCriticalSection(&d3d8_cs);
189 hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
190 LeaveCriticalSection(&d3d8_cs);
192 if (SUCCEEDED(hr)) {
193 pDesc->Type = D3DRTYPE_VERTEXBUFFER;
194 pDesc->Usage = desc.Usage;
195 pDesc->Pool = desc.Pool;
196 pDesc->Size = desc.Size;
197 pDesc->FVF = This->fvf;
198 pDesc->Format = D3DFMT_VERTEXDATA;
201 return hr;
204 const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
206 /* IUnknown */
207 IDirect3DVertexBuffer8Impl_QueryInterface,
208 IDirect3DVertexBuffer8Impl_AddRef,
209 IDirect3DVertexBuffer8Impl_Release,
210 /* IDirect3DResource8 */
211 IDirect3DVertexBuffer8Impl_GetDevice,
212 IDirect3DVertexBuffer8Impl_SetPrivateData,
213 IDirect3DVertexBuffer8Impl_GetPrivateData,
214 IDirect3DVertexBuffer8Impl_FreePrivateData,
215 IDirect3DVertexBuffer8Impl_SetPriority,
216 IDirect3DVertexBuffer8Impl_GetPriority,
217 IDirect3DVertexBuffer8Impl_PreLoad,
218 IDirect3DVertexBuffer8Impl_GetType,
219 /* IDirect3DVertexBuffer8 */
220 IDirect3DVertexBuffer8Impl_Lock,
221 IDirect3DVertexBuffer8Impl_Unlock,
222 IDirect3DVertexBuffer8Impl_GetDesc