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 static 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
);
44 static ULONG WINAPI
IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface
) {
45 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
46 ULONG ref
= InterlockedIncrement(&This
->ref
);
48 TRACE("(%p) : AddRef from %ld\n", This
, ref
- 1);
53 static ULONG WINAPI
IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface
) {
54 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
55 ULONG ref
= InterlockedDecrement(&This
->ref
);
57 TRACE("(%p) : ReleaseRef to %ld\n", This
, ref
);
60 IWineD3DIndexBuffer_Release(This
->wineD3DIndexBuffer
);
61 IUnknown_Release(This
->parentDevice
);
62 HeapFree(GetProcessHeap(), 0, This
);
67 /* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
68 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface
, IDirect3DDevice9
** ppDevice
) {
69 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
70 TRACE("(%p) Relay\n", This
);
71 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9
) This
, ppDevice
);
74 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
75 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
76 TRACE("(%p) Relay\n", This
);
77 return IWineD3DIndexBuffer_SetPrivateData(This
->wineD3DIndexBuffer
, refguid
, pData
, SizeOfData
, Flags
);
80 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
81 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
82 TRACE("(%p) Relay\n", This
);
83 return IWineD3DIndexBuffer_GetPrivateData(This
->wineD3DIndexBuffer
, refguid
, pData
, pSizeOfData
);
86 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
) {
87 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
88 TRACE("(%p) Relay\n", This
);
89 return IWineD3DIndexBuffer_FreePrivateData(This
->wineD3DIndexBuffer
, refguid
);
92 static DWORD WINAPI
IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface
, DWORD PriorityNew
) {
93 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
94 TRACE("(%p) Relay\n", This
);
95 return IWineD3DIndexBuffer_SetPriority(This
->wineD3DIndexBuffer
, PriorityNew
);
98 static DWORD WINAPI
IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface
) {
99 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
100 TRACE("(%p) Relay\n", This
);
101 return IWineD3DIndexBuffer_GetPriority(This
->wineD3DIndexBuffer
);
104 static void WINAPI
IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface
) {
105 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
106 TRACE("(%p) Relay\n", This
);
107 return IWineD3DIndexBuffer_PreLoad(This
->wineD3DIndexBuffer
);
110 static D3DRESOURCETYPE WINAPI
IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface
) {
111 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
112 TRACE("(%p) Relay\n", This
);
113 return IWineD3DIndexBuffer_GetType(This
->wineD3DIndexBuffer
);
116 /* IDirect3DIndexBuffer9 Interface follow: */
117 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface
, UINT OffsetToLock
, UINT SizeToLock
, void** ppbData
, DWORD Flags
) {
118 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
119 TRACE("(%p) Relay\n", This
);
120 return IWineD3DIndexBuffer_Lock(This
->wineD3DIndexBuffer
, OffsetToLock
, SizeToLock
, (BYTE
**)ppbData
, Flags
);
123 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface
) {
124 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
125 TRACE("(%p) Relay\n", This
);
126 return IWineD3DIndexBuffer_Unlock(This
->wineD3DIndexBuffer
);
129 static HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface
, D3DINDEXBUFFER_DESC
*pDesc
) {
130 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
131 TRACE("(%p) Relay\n", This
);
132 return IWineD3DIndexBuffer_GetDesc(This
->wineD3DIndexBuffer
, (WINED3DINDEXBUFFER_DESC
*) pDesc
);
136 static const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl
=
139 IDirect3DIndexBuffer9Impl_QueryInterface
,
140 IDirect3DIndexBuffer9Impl_AddRef
,
141 IDirect3DIndexBuffer9Impl_Release
,
142 /* IDirect3DResource9 */
143 IDirect3DIndexBuffer9Impl_GetDevice
,
144 IDirect3DIndexBuffer9Impl_SetPrivateData
,
145 IDirect3DIndexBuffer9Impl_GetPrivateData
,
146 IDirect3DIndexBuffer9Impl_FreePrivateData
,
147 IDirect3DIndexBuffer9Impl_SetPriority
,
148 IDirect3DIndexBuffer9Impl_GetPriority
,
149 IDirect3DIndexBuffer9Impl_PreLoad
,
150 IDirect3DIndexBuffer9Impl_GetType
,
151 /* IDirect3DIndexBuffer9 */
152 IDirect3DIndexBuffer9Impl_Lock
,
153 IDirect3DIndexBuffer9Impl_Unlock
,
154 IDirect3DIndexBuffer9Impl_GetDesc
158 /* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
159 HRESULT WINAPI
IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface
,
160 UINT Length
, DWORD Usage
, D3DFORMAT Format
, D3DPOOL Pool
,
161 IDirect3DIndexBuffer9
** ppIndexBuffer
, HANDLE
* pSharedHandle
) {
163 IDirect3DIndexBuffer9Impl
*object
;
164 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
165 HRESULT hrc
= D3D_OK
;
167 TRACE("(%p) Relay\n", This
);
168 /* Allocate the storage for the device */
169 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
170 if (NULL
== object
) {
171 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
172 return D3DERR_OUTOFVIDEOMEMORY
;
175 object
->lpVtbl
= &Direct3DIndexBuffer9_Vtbl
;
177 TRACE("Calling wined3d create index buffer\n");
178 hrc
= IWineD3DDevice_CreateIndexBuffer(This
->WineD3DDevice
, Length
, Usage
, Format
, (WINED3DPOOL
) Pool
, &object
->wineD3DIndexBuffer
, pSharedHandle
, (IUnknown
*)object
);
182 FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This
);
183 HeapFree(GetProcessHeap(), 0, object
);
185 IUnknown_AddRef(iface
);
186 object
->parentDevice
= iface
;
187 *ppIndexBuffer
= (LPDIRECT3DINDEXBUFFER9
) object
;
188 TRACE("(%p) : Created index buffer %p\n", This
, object
);