2 * IDirect3DIndexBuffer9 implementation
4 * Copyright 2002-2004 Jason Edmeades
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
27 /* IDirect3DIndexBuffer9 IUnknown parts follow: */
28 HRESULT WINAPI IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
29 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
31 if (IsEqualGUID(riid, &IID_IUnknown)
32 || IsEqualGUID(riid, &IID_IDirect3DResource9)
33 || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)) {
34 IUnknown_AddRef(iface);
39 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
43 ULONG WINAPI IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface) {
44 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
45 ULONG ref = InterlockedIncrement(&This->ref);
47 TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
52 ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface) {
53 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
54 ULONG ref = InterlockedDecrement(&This->ref);
56 TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
59 IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
60 IUnknown_Release(This->parentDevice);
61 HeapFree(GetProcessHeap(), 0, This);
66 /* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
67 HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
68 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
69 TRACE("(%p) Relay\n", This);
70 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
73 HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
74 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
75 TRACE("(%p) Relay\n", This);
76 return IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
79 HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
80 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
81 TRACE("(%p) Relay\n", This);
82 return IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
85 HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid) {
86 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
87 TRACE("(%p) Relay\n", This);
88 return IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
91 DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface, DWORD PriorityNew) {
92 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
93 TRACE("(%p) Relay\n", This);
94 return IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
97 DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface) {
98 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
99 TRACE("(%p) Relay\n", This);
100 return IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
103 void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface) {
104 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
105 TRACE("(%p) Relay\n", This);
106 return IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
109 D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface) {
110 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
111 TRACE("(%p) Relay\n", This);
112 return IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
115 /* IDirect3DIndexBuffer9 Interface follow: */
116 HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
117 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
118 TRACE("(%p) Relay\n", This);
119 return IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
122 HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface) {
123 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
124 TRACE("(%p) Relay\n", This);
125 return IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
128 HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc) {
129 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
130 TRACE("(%p) Relay\n", This);
131 return IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
135 const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl =
138 IDirect3DIndexBuffer9Impl_QueryInterface,
139 IDirect3DIndexBuffer9Impl_AddRef,
140 IDirect3DIndexBuffer9Impl_Release,
141 /* IDirect3DResource9 */
142 IDirect3DIndexBuffer9Impl_GetDevice,
143 IDirect3DIndexBuffer9Impl_SetPrivateData,
144 IDirect3DIndexBuffer9Impl_GetPrivateData,
145 IDirect3DIndexBuffer9Impl_FreePrivateData,
146 IDirect3DIndexBuffer9Impl_SetPriority,
147 IDirect3DIndexBuffer9Impl_GetPriority,
148 IDirect3DIndexBuffer9Impl_PreLoad,
149 IDirect3DIndexBuffer9Impl_GetType,
150 /* IDirect3DIndexBuffer9 */
151 IDirect3DIndexBuffer9Impl_Lock,
152 IDirect3DIndexBuffer9Impl_Unlock,
153 IDirect3DIndexBuffer9Impl_GetDesc
157 /* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
158 HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface,
159 UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
160 IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
162 IDirect3DIndexBuffer9Impl *object;
163 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
164 HRESULT hrc = D3D_OK;
166 TRACE("(%p) Relay\n", This);
167 /* Allocate the storage for the device */
168 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
169 if (NULL == object) {
170 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
171 return D3DERR_OUTOFVIDEOMEMORY;
174 object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
176 TRACE("Calling wined3d create index buffer\n");
177 hrc = IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage, Format, (WINED3DPOOL) Pool, &object->wineD3DIndexBuffer, pSharedHandle, (IUnknown *)object);
181 FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This);
182 HeapFree(GetProcessHeap(), 0, object);
184 IUnknown_AddRef(iface);
185 object->parentDevice = iface;
186 *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object;
187 TRACE("(%p) : Created index buffer %p\n", This, object);