2 * IWineD3DVertexBuffer Implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
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 "wined3d_private.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
27 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
29 /* *******************************************
30 IWineD3DVertexBuffer IUnknown parts follow
31 ******************************************* */
32 HRESULT WINAPI
IWineD3DVertexBufferImpl_QueryInterface(IWineD3DVertexBuffer
*iface
, REFIID riid
, LPVOID
*ppobj
)
34 IWineD3DVertexBufferImpl
*This
= (IWineD3DVertexBufferImpl
*)iface
;
35 WARN("(%p)->(%s,%p) should not be called\n",This
,debugstr_guid(riid
),ppobj
);
39 ULONG WINAPI
IWineD3DVertexBufferImpl_AddRef(IWineD3DVertexBuffer
*iface
) {
40 IWineD3DVertexBufferImpl
*This
= (IWineD3DVertexBufferImpl
*)iface
;
41 TRACE("(%p) : AddRef increasing from %ld\n", This
, This
->resource
.ref
);
42 IUnknown_AddRef(This
->resource
.parent
);
43 return InterlockedIncrement(&This
->resource
.ref
);
46 ULONG WINAPI
IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer
*iface
) {
47 IWineD3DVertexBufferImpl
*This
= (IWineD3DVertexBufferImpl
*)iface
;
49 TRACE("(%p) : Releasing from %ld\n", This
, This
->resource
.ref
);
50 ref
= InterlockedDecrement(&This
->resource
.ref
);
52 HeapFree(GetProcessHeap(), 0, This
->allocatedMemory
);
53 IWineD3DDevice_Release((IWineD3DDevice
*)This
->resource
.wineD3DDevice
);
54 HeapFree(GetProcessHeap(), 0, This
);
56 IUnknown_Release(This
->resource
.parent
); /* Released the reference to the d3dx object */
61 /* ****************************************************
62 IWineD3DVertexBuffer IWineD3DResource parts follow
63 **************************************************** */
64 HRESULT WINAPI
IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer
*iface
, IWineD3DDevice
** ppDevice
) {
65 return IWineD3DResource_GetDevice((IWineD3DResource
*)iface
, ppDevice
);
68 HRESULT WINAPI
IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer
*iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
69 return IWineD3DResource_SetPrivateData((IWineD3DResource
*)iface
, refguid
, pData
, SizeOfData
, Flags
);
72 HRESULT WINAPI
IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer
*iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
73 return IWineD3DResource_GetPrivateData((IWineD3DResource
*)iface
, refguid
, pData
, pSizeOfData
);
76 HRESULT WINAPI
IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer
*iface
, REFGUID refguid
) {
77 return IWineD3DResource_FreePrivateData((IWineD3DResource
*)iface
, refguid
);
80 DWORD WINAPI
IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer
*iface
, DWORD PriorityNew
) {
81 return IWineD3DResource_SetPriority((IWineD3DResource
*)iface
, PriorityNew
);
84 DWORD WINAPI
IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer
*iface
) {
85 return IWineD3DResource_GetPriority((IWineD3DResource
*)iface
);
88 void WINAPI
IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer
*iface
) {
89 return IWineD3DResource_PreLoad((IWineD3DResource
*)iface
);
92 D3DRESOURCETYPE WINAPI
IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer
*iface
) {
93 return IWineD3DResource_GetType((IWineD3DResource
*)iface
);
96 HRESULT WINAPI
IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer
*iface
, IUnknown
**pParent
) {
97 return IWineD3DResource_GetParent((IWineD3DResource
*)iface
, pParent
);
100 /* ******************************************************
101 IWineD3DVertexBuffer IWineD3DVertexBuffer parts follow
102 ****************************************************** */
103 HRESULT WINAPI
IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer
*iface
, UINT OffsetToLock
, UINT SizeToLock
, BYTE
** ppbData
, DWORD Flags
) {
104 IWineD3DVertexBufferImpl
*This
= (IWineD3DVertexBufferImpl
*)iface
;
105 TRACE("(%p) : returning memory of %p (base:%p,offset:%u)\n", This
, This
->allocatedMemory
+ OffsetToLock
, This
->allocatedMemory
, OffsetToLock
);
106 /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
107 *ppbData
= This
->allocatedMemory
+ OffsetToLock
;
110 HRESULT WINAPI
IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer
*iface
) {
111 IWineD3DVertexBufferImpl
*This
= (IWineD3DVertexBufferImpl
*)iface
;
112 TRACE("(%p) : stub\n", This
);
115 HRESULT WINAPI
IWineD3DVertexBufferImpl_GetDesc(IWineD3DVertexBuffer
*iface
, D3DVERTEXBUFFER_DESC
*pDesc
) {
116 IWineD3DVertexBufferImpl
*This
= (IWineD3DVertexBufferImpl
*)iface
;
118 TRACE("(%p)\n", This
);
119 pDesc
->Format
= This
->currentDesc
.Format
;
120 pDesc
->Type
= This
->resource
.resourceType
;
121 pDesc
->Usage
= This
->currentDesc
.Usage
;
122 pDesc
->Pool
= This
->currentDesc
.Pool
;
123 pDesc
->Size
= This
->currentDesc
.Size
;
124 pDesc
->FVF
= This
->currentDesc
.FVF
;
128 IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl
=
130 IWineD3DVertexBufferImpl_QueryInterface
,
131 IWineD3DVertexBufferImpl_AddRef
,
132 IWineD3DVertexBufferImpl_Release
,
133 IWineD3DVertexBufferImpl_GetParent
,
134 IWineD3DVertexBufferImpl_GetDevice
,
135 IWineD3DVertexBufferImpl_SetPrivateData
,
136 IWineD3DVertexBufferImpl_GetPrivateData
,
137 IWineD3DVertexBufferImpl_FreePrivateData
,
138 IWineD3DVertexBufferImpl_SetPriority
,
139 IWineD3DVertexBufferImpl_GetPriority
,
140 IWineD3DVertexBufferImpl_PreLoad
,
141 IWineD3DVertexBufferImpl_GetType
,
142 IWineD3DVertexBufferImpl_Lock
,
143 IWineD3DVertexBufferImpl_Unlock
,
144 IWineD3DVertexBufferImpl_GetDesc