2 * IDirect3DIndexBuffer8 implementation
4 * Copyright 2002 Jason Edmeades
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "wine/debug.h"
31 #include "d3d8_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
35 /* IDirect3DIndexBuffer8 IUnknown parts follow: */
36 HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface,REFIID riid,LPVOID *ppobj)
38 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
40 if (IsEqualGUID(riid, &IID_IUnknown)
41 || IsEqualGUID(riid, &IID_IDirect3DResource8)
42 || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
43 IDirect3DIndexBuffer8Impl_AddRef(iface);
48 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
52 ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
53 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
54 ULONG ref = InterlockedIncrement(&This->ref);
56 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
61 ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
62 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
63 ULONG ref = InterlockedDecrement(&This->ref);
65 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
67 if (ref == 0 && 0 == This->refInt) {
68 HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
69 HeapFree(GetProcessHeap(), 0, This);
70 } else if (0 == ref) {
71 WARN("(%p) : The application failed to set indicies NULL before releasing the index buffer, leak\n", This);
78 ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRefInt(LPDIRECT3DINDEXBUFFER8 iface) {
79 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
80 ULONG refInt = InterlockedIncrement(&This->refInt);
82 TRACE("(%p) : AddRefInt from %ld\n", This, refInt - 1);
87 ULONG WINAPI IDirect3DIndexBuffer8Impl_ReleaseInt(LPDIRECT3DINDEXBUFFER8 iface) {
88 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
89 ULONG refInt = InterlockedDecrement(&This->refInt);
91 TRACE("(%p) : ReleaseRefInt to %ld\n", This, refInt);
93 if (0 == This->ref && 0 == refInt) {
94 WARN("(%p) : Cleaning up after the calling application failed to release the indicies properly\n", This);
95 HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
96 HeapFree(GetProcessHeap(), 0, This);
103 /* IDirect3DResource Interface follow: */
104 HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
105 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
106 TRACE("(%p) : returning %p\n", This, This->Device);
107 *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
108 IDirect3DDevice8Impl_AddRef(*ppDevice);
111 HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
112 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
113 FIXME("(%p) : stub\n", This); return D3D_OK;
115 HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
116 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
117 FIXME("(%p) : stub\n", This); return D3D_OK;
119 HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
120 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
121 FIXME("(%p) : stub\n", This); return D3D_OK;
123 DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
124 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
125 FIXME("(%p) : stub\n", This); return D3D_OK;
127 DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
128 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
129 FIXME("(%p) : stub\n", This); return D3D_OK;
131 void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
132 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
133 FIXME("(%p) : stub\n", This);
135 D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
136 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
137 TRACE("(%p) : returning %d\n", This, This->ResourceType);
138 return This->ResourceType;
141 /* IDirect3DIndexBuffer8 */
142 HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
143 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
144 TRACE("(%p) : no locking yet, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags);
145 *ppbData = (BYTE *)This->allocatedMemory + OffsetToLock;
149 HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
150 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
151 TRACE("(%p) : stub\n", This);
154 HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
155 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
157 TRACE("(%p) : copying into %p\n", This, pDesc);
158 memcpy(pDesc, &This->currentDesc, sizeof(D3DINDEXBUFFER_DESC));
162 const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
164 IDirect3DIndexBuffer8Impl_QueryInterface,
165 IDirect3DIndexBuffer8Impl_AddRef,
166 IDirect3DIndexBuffer8Impl_Release,
167 IDirect3DIndexBuffer8Impl_GetDevice,
168 IDirect3DIndexBuffer8Impl_SetPrivateData,
169 IDirect3DIndexBuffer8Impl_GetPrivateData,
170 IDirect3DIndexBuffer8Impl_FreePrivateData,
171 IDirect3DIndexBuffer8Impl_SetPriority,
172 IDirect3DIndexBuffer8Impl_GetPriority,
173 IDirect3DIndexBuffer8Impl_PreLoad,
174 IDirect3DIndexBuffer8Impl_GetType,
175 IDirect3DIndexBuffer8Impl_Lock,
176 IDirect3DIndexBuffer8Impl_Unlock,
177 IDirect3DIndexBuffer8Impl_GetDesc