2 * IWineD3DIndexBuffer Implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
7 * Copyright 2005 Oliver Stieber
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "wined3d_private.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
28 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
30 /* *******************************************
31 IWineD3DIndexBuffer IUnknown parts follow
32 ******************************************* */
33 HRESULT WINAPI IWineD3DIndexBufferImpl_QueryInterface(IWineD3DIndexBuffer *iface, REFIID riid, LPVOID *ppobj)
35 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
36 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
37 if (IsEqualGUID(riid, &IID_IUnknown)
38 || IsEqualGUID(riid, &IID_IWineD3DBase)
39 || IsEqualGUID(riid, &IID_IWineD3DResource)
40 || IsEqualGUID(riid, &IID_IWineD3DIndexBuffer)){
41 IUnknown_AddRef(iface);
48 ULONG WINAPI IWineD3DIndexBufferImpl_AddRef(IWineD3DIndexBuffer *iface) {
49 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
50 ULONG ref = InterlockedIncrement(&This->resource.ref);
51 TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
55 ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface) {
56 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
57 ULONG ref = InterlockedDecrement(&This->resource.ref);
58 TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
60 IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
61 HeapFree(GetProcessHeap(), 0, This);
66 /* ****************************************************
67 IWineD3DIndexBuffer IWineD3DResource parts follow
68 **************************************************** */
69 HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice** ppDevice) {
70 return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
73 HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
74 return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
77 HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
78 return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
81 HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid) {
82 return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
85 DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew) {
86 return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
89 DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface) {
90 return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
93 void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface) {
94 return IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
97 D3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface) {
98 return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
101 HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent) {
102 return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
105 /* ******************************************************
106 IWineD3DIndexBuffer IWineD3DIndexBuffer parts follow
107 ****************************************************** */
108 HRESULT WINAPI IWineD3DIndexBufferImpl_Lock(IWineD3DIndexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
109 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
110 TRACE("(%p) : no real locking yet, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags);
111 *ppbData = (BYTE *)This->resource.allocatedMemory + OffsetToLock;
114 HRESULT WINAPI IWineD3DIndexBufferImpl_Unlock(IWineD3DIndexBuffer *iface) {
115 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
116 TRACE("(%p) : stub\n", This);
119 HRESULT WINAPI IWineD3DIndexBufferImpl_GetDesc(IWineD3DIndexBuffer *iface, D3DINDEXBUFFER_DESC *pDesc) {
120 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
122 TRACE("(%p)\n", This);
123 pDesc->Format = This->resource.format;
124 pDesc->Type = This->resource.resourceType;
125 pDesc->Usage = This->resource.usage;
126 pDesc->Pool = This->resource.pool;
127 pDesc->Size = This->resource.size;
131 const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl =
134 IWineD3DIndexBufferImpl_QueryInterface,
135 IWineD3DIndexBufferImpl_AddRef,
136 IWineD3DIndexBufferImpl_Release,
137 /* IWineD3DResource */
138 IWineD3DIndexBufferImpl_GetParent,
139 IWineD3DIndexBufferImpl_GetDevice,
140 IWineD3DIndexBufferImpl_SetPrivateData,
141 IWineD3DIndexBufferImpl_GetPrivateData,
142 IWineD3DIndexBufferImpl_FreePrivateData,
143 IWineD3DIndexBufferImpl_SetPriority,
144 IWineD3DIndexBufferImpl_GetPriority,
145 IWineD3DIndexBufferImpl_PreLoad,
146 IWineD3DIndexBufferImpl_GetType,
147 /* IWineD3DIndexBuffer */
148 IWineD3DIndexBufferImpl_Lock,
149 IWineD3DIndexBufferImpl_Unlock,
150 IWineD3DIndexBufferImpl_GetDesc