Changed the CreateDC driver entry point to use an HDC instead of a DC
[wine] / dlls / d3d8 / indexbuffer.c
1 /*
2  * IDirect3DIndexBuffer8 implementation
3  *
4  * Copyright 2002 Jason Edmeades
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "wingdi.h"
29 #include "wine/debug.h"
30
31 #include "d3d8_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
34
35 /* IDirect3DIndexBuffer8 IUnknown parts follow: */
36 HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface,REFIID riid,LPVOID *ppobj)
37 {
38     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
39
40     if (IsEqualGUID(riid, &IID_IUnknown)
41         || IsEqualGUID(riid, &IID_IDirect3DResource8)
42         || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
43         IDirect3DIndexBuffer8Impl_AddRef(iface);
44         *ppobj = This;
45         return D3D_OK;
46     }
47
48     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
49     return E_NOINTERFACE;
50 }
51
52 ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
53     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
54     TRACE("(%p) : AddRef from %ld\n", This, This->ref);
55     return ++(This->ref);
56 }
57
58 ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
59     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
60     ULONG ref = --This->ref;
61     TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
62     if (ref == 0) {
63         HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
64         HeapFree(GetProcessHeap(), 0, This);
65     }
66     return ref;
67 }
68
69 /* IDirect3DResource Interface follow: */
70 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8** ppDevice) {
71     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
72     TRACE("(%p) : returning %p\n", This, This->Device);
73     *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
74     IDirect3DDevice8Impl_AddRef(*ppDevice);
75     return D3D_OK;
76 }
77 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
78     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
79     FIXME("(%p) : stub\n", This);    return D3D_OK;
80 }
81 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
82     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
83     FIXME("(%p) : stub\n", This);    return D3D_OK;
84 }
85 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
86     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
87     FIXME("(%p) : stub\n", This);    return D3D_OK;
88 }
89 DWORD    WINAPI        IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
90     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
91     FIXME("(%p) : stub\n", This);    return D3D_OK;
92 }
93 DWORD    WINAPI        IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
94     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
95     FIXME("(%p) : stub\n", This);    return D3D_OK;
96 }
97 void     WINAPI        IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
98     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
99     FIXME("(%p) : stub\n", This);
100 }
101 D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
102     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
103     TRACE("(%p) : returning %d\n", This, This->ResourceType);
104     return This->ResourceType;
105 }
106
107 /* IDirect3DIndexBuffer8 */
108 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE** ppbData, DWORD Flags) {
109     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
110     TRACE("(%p) : no locking yet, offset %d, size %d, Flags=%lx\n", This, OffsetToLock, SizeToLock, Flags);
111     *ppbData = (BYTE *)This->allocatedMemory + OffsetToLock;
112     return D3D_OK;
113 }
114
115 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
116     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
117     TRACE("(%p) : stub\n", This);
118     return D3D_OK;
119 }
120 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
121     ICOM_THIS(IDirect3DIndexBuffer8Impl,iface);
122
123     TRACE("(%p) : copying into %p\n", This, pDesc);
124     memcpy(pDesc, &This->currentDesc, sizeof(D3DINDEXBUFFER_DESC));
125     return D3D_OK;
126 }
127
128 ICOM_VTABLE(IDirect3DIndexBuffer8) Direct3DIndexBuffer8_Vtbl =
129 {
130     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
131     IDirect3DIndexBuffer8Impl_QueryInterface,
132     IDirect3DIndexBuffer8Impl_AddRef,
133     IDirect3DIndexBuffer8Impl_Release,
134     IDirect3DIndexBuffer8Impl_GetDevice,
135     IDirect3DIndexBuffer8Impl_SetPrivateData,
136     IDirect3DIndexBuffer8Impl_GetPrivateData,
137     IDirect3DIndexBuffer8Impl_FreePrivateData,
138     IDirect3DIndexBuffer8Impl_SetPriority,
139     IDirect3DIndexBuffer8Impl_GetPriority,
140     IDirect3DIndexBuffer8Impl_PreLoad,
141     IDirect3DIndexBuffer8Impl_GetType,
142     IDirect3DIndexBuffer8Impl_Lock,
143     IDirect3DIndexBuffer8Impl_Unlock,
144     IDirect3DIndexBuffer8Impl_GetDesc
145 };