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
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
);
38 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
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);
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
);
60 EnterCriticalSection(&d3d8_cs
);
61 IWineD3DVertexBuffer_Release(This
->wineD3DVertexBuffer
);
62 LeaveCriticalSection(&d3d8_cs
);
63 IUnknown_Release(This
->parentDevice
);
64 HeapFree(GetProcessHeap(), 0, This
);
70 /* IDirect3DVertexBuffer8 IDirect3DResource8 Interface follow: */
71 static HRESULT WINAPI
IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface
, IDirect3DDevice8
**ppDevice
) {
72 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
74 TRACE("(%p) Relay\n", This
);
76 EnterCriticalSection(&d3d8_cs
);
77 hr
= IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8
) This
, ppDevice
);
78 LeaveCriticalSection(&d3d8_cs
);
82 static HRESULT WINAPI
IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface
, REFGUID refguid
, CONST
void *pData
, DWORD SizeOfData
, DWORD Flags
) {
83 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
85 TRACE("(%p) Relay\n", This
);
87 EnterCriticalSection(&d3d8_cs
);
88 hr
= IWineD3DVertexBuffer_SetPrivateData(This
->wineD3DVertexBuffer
, refguid
, pData
, SizeOfData
, Flags
);
89 LeaveCriticalSection(&d3d8_cs
);
93 static HRESULT WINAPI
IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface
, REFGUID refguid
, void *pData
, DWORD
*pSizeOfData
) {
94 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
96 TRACE("(%p) Relay\n", This
);
98 EnterCriticalSection(&d3d8_cs
);
99 hr
= IWineD3DVertexBuffer_GetPrivateData(This
->wineD3DVertexBuffer
, refguid
, pData
, pSizeOfData
);
100 LeaveCriticalSection(&d3d8_cs
);
104 static HRESULT WINAPI
IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface
, REFGUID refguid
) {
105 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
107 TRACE("(%p) Relay\n", This
);
109 EnterCriticalSection(&d3d8_cs
);
110 hr
= IWineD3DVertexBuffer_FreePrivateData(This
->wineD3DVertexBuffer
, refguid
);
111 LeaveCriticalSection(&d3d8_cs
);
115 static DWORD WINAPI
IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface
, DWORD PriorityNew
) {
116 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
118 TRACE("(%p) Relay\n", This
);
120 EnterCriticalSection(&d3d8_cs
);
121 ret
= IWineD3DVertexBuffer_SetPriority(This
->wineD3DVertexBuffer
, PriorityNew
);
122 LeaveCriticalSection(&d3d8_cs
);
126 static DWORD WINAPI
IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface
) {
127 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
129 TRACE("(%p) Relay\n", This
);
131 EnterCriticalSection(&d3d8_cs
);
132 ret
= IWineD3DVertexBuffer_GetPriority(This
->wineD3DVertexBuffer
);
133 LeaveCriticalSection(&d3d8_cs
);
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
);
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
;
161 TRACE("(%p) Relay\n", This
);
163 EnterCriticalSection(&d3d8_cs
);
164 hr
= IWineD3DVertexBuffer_Lock(This
->wineD3DVertexBuffer
, OffsetToLock
, SizeToLock
, ppbData
, Flags
);
165 LeaveCriticalSection(&d3d8_cs
);
169 static HRESULT WINAPI
IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface
) {
170 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
172 TRACE("(%p) Relay\n", This
);
174 EnterCriticalSection(&d3d8_cs
);
175 hr
= IWineD3DVertexBuffer_Unlock(This
->wineD3DVertexBuffer
);
176 LeaveCriticalSection(&d3d8_cs
);
180 static HRESULT WINAPI
IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface
, D3DVERTEXBUFFER_DESC
*pDesc
) {
181 IDirect3DVertexBuffer8Impl
*This
= (IDirect3DVertexBuffer8Impl
*)iface
;
183 TRACE("(%p) Relay\n", This
);
185 EnterCriticalSection(&d3d8_cs
);
186 hr
= IWineD3DVertexBuffer_GetDesc(This
->wineD3DVertexBuffer
, (WINED3DVERTEXBUFFER_DESC
*) pDesc
);
187 LeaveCriticalSection(&d3d8_cs
);
189 if (SUCCEEDED(hr
)) pDesc
->Format
= d3dformat_from_wined3dformat(pDesc
->Format
);
194 const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl
=
197 IDirect3DVertexBuffer8Impl_QueryInterface
,
198 IDirect3DVertexBuffer8Impl_AddRef
,
199 IDirect3DVertexBuffer8Impl_Release
,
200 /* IDirect3DResource8 */
201 IDirect3DVertexBuffer8Impl_GetDevice
,
202 IDirect3DVertexBuffer8Impl_SetPrivateData
,
203 IDirect3DVertexBuffer8Impl_GetPrivateData
,
204 IDirect3DVertexBuffer8Impl_FreePrivateData
,
205 IDirect3DVertexBuffer8Impl_SetPriority
,
206 IDirect3DVertexBuffer8Impl_GetPriority
,
207 IDirect3DVertexBuffer8Impl_PreLoad
,
208 IDirect3DVertexBuffer8Impl_GetType
,
209 /* IDirect3DVertexBuffer8 */
210 IDirect3DVertexBuffer8Impl_Lock
,
211 IDirect3DVertexBuffer8Impl_Unlock
,
212 IDirect3DVertexBuffer8Impl_GetDesc