2 * IWineD3DIndexBuffer 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 IWineD3DIndexBuffer IUnknown parts follow
31 ******************************************* */
32 HRESULT WINAPI IWineD3DIndexBufferImpl_QueryInterface(IWineD3DIndexBuffer *iface, REFIID riid, LPVOID *ppobj)
34 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
35 TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
36 if (IsEqualGUID(riid, &IID_IUnknown)
37 || IsEqualGUID(riid, &IID_IWineD3DResource)
38 || IsEqualGUID(riid, &IID_IWineD3DIndexBuffer)){
39 IUnknown_AddRef(iface);
46 ULONG WINAPI IWineD3DIndexBufferImpl_AddRef(IWineD3DIndexBuffer *iface) {
47 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
48 ULONG ref = InterlockedIncrement(&This->resource.ref);
49 TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
53 ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface) {
54 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
55 ULONG ref = InterlockedDecrement(&This->resource.ref);
56 TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
58 IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
59 HeapFree(GetProcessHeap(), 0, This);
64 /* ****************************************************
65 IWineD3DIndexBuffer IWineD3DResource parts follow
66 **************************************************** */
67 HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice** ppDevice) {
68 return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
71 HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
72 return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
75 HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
76 return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
79 HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid) {
80 return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
83 DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew) {
84 return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
87 DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface) {
88 return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
91 void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface) {
92 return IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
95 D3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface) {
96 return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
99 HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent) {
100 return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
103 /* ******************************************************
104 IWineD3DIndexBuffer IWineD3DIndexBuffer parts follow
105 ****************************************************** */
106 HRESULT WINAPI IWineD3DIndexBufferImpl_Lock(IWineD3DIndexBuffer *iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
107 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
108 TRACE("(%p) : no real locking yet, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags);
109 *ppbData = (BYTE *)This->resource.allocatedMemory + OffsetToLock;
112 HRESULT WINAPI IWineD3DIndexBufferImpl_Unlock(IWineD3DIndexBuffer *iface) {
113 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
114 TRACE("(%p) : stub\n", This);
117 HRESULT WINAPI IWineD3DIndexBufferImpl_GetDesc(IWineD3DIndexBuffer *iface, D3DINDEXBUFFER_DESC *pDesc) {
118 IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
120 TRACE("(%p)\n", This);
121 pDesc->Format = This->resource.format;
122 pDesc->Type = This->resource.resourceType;
123 pDesc->Usage = This->resource.usage;
124 pDesc->Pool = This->resource.pool;
125 pDesc->Size = This->resource.size;
129 const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl =
131 IWineD3DIndexBufferImpl_QueryInterface,
132 IWineD3DIndexBufferImpl_AddRef,
133 IWineD3DIndexBufferImpl_Release,
134 IWineD3DIndexBufferImpl_GetParent,
135 IWineD3DIndexBufferImpl_GetDevice,
136 IWineD3DIndexBufferImpl_SetPrivateData,
137 IWineD3DIndexBufferImpl_GetPrivateData,
138 IWineD3DIndexBufferImpl_FreePrivateData,
139 IWineD3DIndexBufferImpl_SetPriority,
140 IWineD3DIndexBufferImpl_GetPriority,
141 IWineD3DIndexBufferImpl_PreLoad,
142 IWineD3DIndexBufferImpl_GetType,
143 IWineD3DIndexBufferImpl_Lock,
144 IWineD3DIndexBufferImpl_Unlock,
145 IWineD3DIndexBufferImpl_GetDesc