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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 HeapFree(GetProcessHeap(), 0, This
);
65 /* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
66 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface
, IDirect3DDevice9
** ppDevice
) {
67 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
68 TRACE("(%p) Relay\n", This
);
69 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9
) This
, ppDevice
);
72 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
73 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
74 TRACE("(%p) Relay\n", This
);
75 return IWineD3DIndexBuffer_SetPrivateData(This
->wineD3DIndexBuffer
, refguid
, pData
, SizeOfData
, Flags
);
78 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
79 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
80 TRACE("(%p) Relay\n", This
);
81 return IWineD3DIndexBuffer_GetPrivateData(This
->wineD3DIndexBuffer
, refguid
, pData
, pSizeOfData
);
84 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
) {
85 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
86 TRACE("(%p) Relay\n", This
);
87 return IWineD3DIndexBuffer_FreePrivateData(This
->wineD3DIndexBuffer
, refguid
);
90 DWORD WINAPI
IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface
, DWORD PriorityNew
) {
91 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
92 TRACE("(%p) Relay\n", This
);
93 return IWineD3DIndexBuffer_SetPriority(This
->wineD3DIndexBuffer
, PriorityNew
);
96 DWORD WINAPI
IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface
) {
97 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
98 TRACE("(%p) Relay\n", This
);
99 return IWineD3DIndexBuffer_GetPriority(This
->wineD3DIndexBuffer
);
102 void WINAPI
IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface
) {
103 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
104 TRACE("(%p) Relay\n", This
);
105 return IWineD3DIndexBuffer_PreLoad(This
->wineD3DIndexBuffer
);
108 D3DRESOURCETYPE WINAPI
IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface
) {
109 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
110 TRACE("(%p) Relay\n", This
);
111 return IWineD3DIndexBuffer_GetType(This
->wineD3DIndexBuffer
);
114 /* IDirect3DIndexBuffer9 Interface follow: */
115 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface
, UINT OffsetToLock
, UINT SizeToLock
, void** ppbData
, DWORD Flags
) {
116 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
117 TRACE("(%p) Relay\n", This
);
118 return IWineD3DIndexBuffer_Lock(This
->wineD3DIndexBuffer
, OffsetToLock
, SizeToLock
, (BYTE
**)ppbData
, Flags
);
121 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface
) {
122 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
123 TRACE("(%p) Relay\n", This
);
124 return IWineD3DIndexBuffer_Unlock(This
->wineD3DIndexBuffer
);
127 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface
, D3DINDEXBUFFER_DESC
*pDesc
) {
128 IDirect3DIndexBuffer9Impl
*This
= (IDirect3DIndexBuffer9Impl
*)iface
;
129 TRACE("(%p) Relay\n", This
);
130 return IWineD3DIndexBuffer_GetDesc(This
->wineD3DIndexBuffer
, pDesc
);
134 const IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl
=
137 IDirect3DIndexBuffer9Impl_QueryInterface
,
138 IDirect3DIndexBuffer9Impl_AddRef
,
139 IDirect3DIndexBuffer9Impl_Release
,
140 /* IDirect3DResource9 */
141 IDirect3DIndexBuffer9Impl_GetDevice
,
142 IDirect3DIndexBuffer9Impl_SetPrivateData
,
143 IDirect3DIndexBuffer9Impl_GetPrivateData
,
144 IDirect3DIndexBuffer9Impl_FreePrivateData
,
145 IDirect3DIndexBuffer9Impl_SetPriority
,
146 IDirect3DIndexBuffer9Impl_GetPriority
,
147 IDirect3DIndexBuffer9Impl_PreLoad
,
148 IDirect3DIndexBuffer9Impl_GetType
,
149 /* IDirect3DIndexBuffer9 */
150 IDirect3DIndexBuffer9Impl_Lock
,
151 IDirect3DIndexBuffer9Impl_Unlock
,
152 IDirect3DIndexBuffer9Impl_GetDesc
156 /* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
157 HRESULT WINAPI
IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface
,
158 UINT Length
, DWORD Usage
, D3DFORMAT Format
, D3DPOOL Pool
,
159 IDirect3DIndexBuffer9
** ppIndexBuffer
, HANDLE
* pSharedHandle
) {
161 IDirect3DIndexBuffer9Impl
*object
;
162 IDirect3DDevice9Impl
*This
= (IDirect3DDevice9Impl
*)iface
;
163 HRESULT hrc
= D3D_OK
;
165 TRACE("(%p) Relay\n", This
);
166 /* Allocate the storage for the device */
167 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
));
168 if (NULL
== object
) {
169 FIXME("Allocation of memory failed\n");
170 *ppIndexBuffer
= NULL
;
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
, Pool
, &object
->wineD3DIndexBuffer
, pSharedHandle
, (IUnknown
*)object
);
180 FIXME("(%p) call to IWineD3DDevice_CreateIndexBuffer failed\n", This
);
181 HeapFree(GetProcessHeap(), 0, object
);
182 *ppIndexBuffer
= NULL
;
184 *ppIndexBuffer
= (LPDIRECT3DINDEXBUFFER9
) object
;