wined3d: Use WINED3DSWAPEFFECT in the wined3d headers and code.
[wine] / dlls / d3d8 / indexbuffer.c
1 /*
2  * IDirect3DIndexBuffer8 implementation
3  *
4  * Copyright 2005 Oliver Stieber
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 #include "d3d8_private.h"
23
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
25
26 /* IDirect3DIndexBuffer8 IUnknown parts follow: */
27 HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
28     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
29
30     if (IsEqualGUID(riid, &IID_IUnknown)
31         || IsEqualGUID(riid, &IID_IDirect3DResource8)
32         || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
33         IUnknown_AddRef(iface);
34         *ppobj = This;
35         return D3D_OK;
36     }
37
38     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
39     return E_NOINTERFACE;
40 }
41
42 ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
43     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
44     ULONG ref = InterlockedIncrement(&This->ref);
45
46     TRACE("(%p) : AddRef from %ld\n", This, ref - 1);
47
48     return ref;
49 }
50
51 ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
52     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
53     ULONG ref = InterlockedDecrement(&This->ref);
54
55     TRACE("(%p) : ReleaseRef to %ld\n", This, ref);
56
57     if (ref == 0) {
58         IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
59         HeapFree(GetProcessHeap(), 0, This);
60     }
61     return ref;
62 }
63
64 /* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
65 HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
66     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
67     TRACE("(%p) Relay\n", This);
68     return IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
69 }
70
71 HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
72     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
73     TRACE("(%p) Relay\n", This);
74     return IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
75 }
76
77 HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
78     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
79     TRACE("(%p) Relay\n", This);
80     return IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
81 }
82
83 HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
84     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
85     TRACE("(%p) Relay\n", This);
86     return IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
87 }
88
89 DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
90     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
91     TRACE("(%p) Relay\n", This);
92     return IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
93 }
94
95 DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
96     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
97     TRACE("(%p) Relay\n", This);
98     return IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
99 }
100
101 void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
102     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
103     TRACE("(%p) Relay\n", This);
104     return IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
105 }
106
107 D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
108     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
109     TRACE("(%p) Relay\n", This);
110     return IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
111 }
112
113 /* IDirect3DIndexBuffer8 Interface follow: */
114 HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
115     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
116     TRACE("(%p) Relay\n", This);
117     return IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
118 }
119
120 HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
121     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
122     TRACE("(%p) Relay\n", This);
123     return IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
124 }
125
126 HRESULT  WINAPI        IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
127     IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
128     TRACE("(%p) Relay\n", This);
129     return IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
130 }
131
132
133 const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
134 {
135     /* IUnknown */
136     IDirect3DIndexBuffer8Impl_QueryInterface,
137     IDirect3DIndexBuffer8Impl_AddRef,
138     IDirect3DIndexBuffer8Impl_Release,
139     /* IDirect3DResource8 */
140     IDirect3DIndexBuffer8Impl_GetDevice,
141     IDirect3DIndexBuffer8Impl_SetPrivateData,
142     IDirect3DIndexBuffer8Impl_GetPrivateData,
143     IDirect3DIndexBuffer8Impl_FreePrivateData,
144     IDirect3DIndexBuffer8Impl_SetPriority,
145     IDirect3DIndexBuffer8Impl_GetPriority,
146     IDirect3DIndexBuffer8Impl_PreLoad,
147     IDirect3DIndexBuffer8Impl_GetType,
148     /* IDirect3DIndexBuffer8 */
149     IDirect3DIndexBuffer8Impl_Lock,
150     IDirect3DIndexBuffer8Impl_Unlock,
151     IDirect3DIndexBuffer8Impl_GetDesc
152 };