2 * IDirect3DIndexBuffer9 implementation
4 * Copyright 2002-2003 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
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
32 #include "wine/debug.h"
34 #include "d3d9_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
38 /* IDirect3DIndexBuffer9 IUnknown parts follow: */
39 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface
, REFIID riid
, LPVOID
* ppobj
) {
40 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
42 if (IsEqualGUID(riid
, &IID_IUnknown
)
43 || IsEqualGUID(riid
, &IID_IDirect3DResource9
)
44 || IsEqualGUID(riid
, &IID_IDirect3DIndexBuffer9
)) {
45 IDirect3DIndexBuffer9Impl_AddRef(iface
);
50 WARN("(%p)->(%s,%p),not found\n", This
, debugstr_guid(riid
), ppobj
);
54 ULONG WINAPI
IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface
) {
55 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
56 TRACE("(%p) : AddRef from %ld\n", This
, This
->ref
);
60 ULONG WINAPI
IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface
) {
61 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
62 ULONG ref
= --This
->ref
;
63 TRACE("(%p) : ReleaseRef to %ld\n", This
, This
->ref
);
65 HeapFree(GetProcessHeap(), 0, This
->allocatedMemory
);
66 HeapFree(GetProcessHeap(), 0, This
);
71 /* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
72 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface
, IDirect3DDevice9
** ppDevice
) {
73 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
74 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9
) This
, ppDevice
);
77 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
) {
78 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
79 FIXME("(%p) : stub\n", This
);
83 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
) {
84 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
85 FIXME("(%p) : stub\n", This
);
89 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface
, REFGUID refguid
) {
90 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
91 FIXME("(%p) : stub\n", This
);
95 DWORD WINAPI
IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface
, DWORD PriorityNew
) {
96 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
97 return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9
) This
, PriorityNew
);
100 DWORD WINAPI
IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface
) {
101 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
102 return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9
) This
);
105 void WINAPI
IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface
) {
106 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
107 FIXME("(%p) : stub\n", This
);
111 D3DRESOURCETYPE WINAPI
IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface
) {
112 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
113 return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9
) This
);
116 /* IDirect3DIndexBuffer9 Interface follow: */
117 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface
, UINT OffsetToLock
, UINT SizeToLock
, void** ppbData
, DWORD Flags
) {
118 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
119 FIXME("(%p) : stub\n", This
);
123 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface
) {
124 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
125 FIXME("(%p) : stub\n", This
);
129 HRESULT WINAPI
IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface
, D3DINDEXBUFFER_DESC
*pDesc
) {
130 ICOM_THIS(IDirect3DIndexBuffer9Impl
,iface
);
131 TRACE("(%p) : copying into %p\n", This
, pDesc
);
132 memcpy(pDesc
, &This
->myDesc
, sizeof(D3DINDEXBUFFER_DESC
));
137 ICOM_VTABLE(IDirect3DIndexBuffer9
) Direct3DIndexBuffer9_Vtbl
=
139 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
140 IDirect3DIndexBuffer9Impl_QueryInterface
,
141 IDirect3DIndexBuffer9Impl_AddRef
,
142 IDirect3DIndexBuffer9Impl_Release
,
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 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
) {
161 IDirect3DIndexBuffer9Impl
*object
;
163 ICOM_THIS(IDirect3DDevice9Impl
,iface
);
165 /*TRACE("(%p) : Len=%d, Use=%lx, Format=(%u,%s), Pool=%d\n", This, Length, Usage, Format, debug_d3dformat(Format), Pool);*/
167 /* Allocate the storage for the device */
168 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirect3DIndexBuffer9Impl
));
169 object
->lpVtbl
= &Direct3DIndexBuffer9_Vtbl
;
171 object
->Device
= This
;
173 object
->ResourceType
= D3DRTYPE_INDEXBUFFER
;
175 object
->allocatedMemory
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, Length
);
176 object
->myDesc
.Type
= D3DRTYPE_INDEXBUFFER
;
177 object
->myDesc
.Usage
= Usage
;
178 object
->myDesc
.Pool
= Pool
;
179 object
->myDesc
.Format
= Format
;
180 object
->myDesc
.Size
= Length
;
182 TRACE("(%p) : Iface@%p allocatedMem @ %p\n", This
, object
, object
->allocatedMemory
);
184 *ppIndexBuffer
= (LPDIRECT3DINDEXBUFFER9
) object
;