Keep track of per-column information inside the listview.
[wine] / dlls / ddraw / direct3d / main.c
1 /*
2  * Copyright 2000 Marcus Meissner
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #include "config.h"
20
21 #include <assert.h>
22 #ifdef HAVE_UNISTD_H
23 # include <unistd.h>
24 #endif
25 #include <fcntl.h>
26 #include <string.h>
27 #include <stdio.h>
28
29 #include "winerror.h"
30 #include "ddraw.h"
31 #include "d3d.h"
32 #include "wine/debug.h"
33
34 #include "d3d_private.h"
35
36 WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
37
38 static ICOM_VTABLE(IDirect3D) d3dvt;
39 static ICOM_VTABLE(IDirect3D2) d3d2vt;
40
41 /*******************************************************************************
42  *                              IDirect3D
43  */
44 HRESULT WINAPI IDirect3DImpl_QueryInterface(
45     LPDIRECT3D iface,REFIID refiid,LPVOID *obj
46 ) {
47     ICOM_THIS(IDirect3DImpl,iface);
48     /* FIXME: Not sure if this is correct */
49
50     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
51     if (( IsEqualGUID( &IID_IDirectDraw,  refiid ) ) ||
52         ( IsEqualGUID (&IID_IDirectDraw2, refiid ) ) ||
53         ( IsEqualGUID( &IID_IDirectDraw4, refiid ) )
54     ) {
55         *obj = This->ddraw;
56         IDirect3D_AddRef(iface);
57         TRACE("  Creating IDirectDrawX interface (%p)\n", *obj);
58         return S_OK;
59     }
60     if (( IsEqualGUID( &IID_IDirect3D, refiid ) ) ||
61         ( IsEqualGUID( &IID_IUnknown,  refiid ) ) ) {
62         *obj = This;
63         IDirect3D_AddRef(iface);
64         TRACE("  Creating IDirect3D interface (%p)\n", *obj);
65         return S_OK;
66     }
67     if ( IsEqualGUID( &IID_IDirect3D2, refiid ) ) {
68         IDirect3D2Impl*  d3d;
69
70         d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
71         d3d->ref = 1;
72         d3d->ddraw = This->ddraw;
73         IDirect3D_AddRef(iface);
74         ICOM_VTBL(d3d) = &d3d2vt;
75         *obj = d3d;
76         TRACE("  Creating IDirect3D2 interface (%p)\n", *obj);
77         return S_OK;
78     }
79     FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
80     return OLE_E_ENUM_NOMORE;
81 }
82
83 ULONG WINAPI IDirect3DImpl_AddRef(LPDIRECT3D iface) {
84     ICOM_THIS(IDirect3DImpl,iface);
85     TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
86
87     return ++(This->ref);
88 }
89
90 ULONG WINAPI IDirect3DImpl_Release(LPDIRECT3D iface)
91 {
92     ICOM_THIS(IDirect3DImpl,iface);
93     TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
94
95     if (!--(This->ref)) {
96         IDirectDraw2_Release((IDirectDraw2*)This->ddraw);
97         HeapFree(GetProcessHeap(),0,This);
98         return S_OK;
99     }
100     return This->ref;
101 }
102
103 HRESULT WINAPI IDirect3DImpl_Initialize(LPDIRECT3D iface,REFIID refiid) {
104     ICOM_THIS(IDirect3DImpl,iface);
105     /* FIXME: Not sure if this is correct */
106     FIXME("(%p)->(%s):stub.\n",This,debugstr_guid(refiid));
107     return DDERR_ALREADYINITIALIZED;
108 }
109
110 HRESULT WINAPI IDirect3DImpl_EnumDevices(
111     LPDIRECT3D iface, LPD3DENUMDEVICESCALLBACK cb, LPVOID context
112 ) {
113     ICOM_THIS(IDirect3DImpl,iface);
114     FIXME("(%p)->(%p,%p),stub!\n",This,cb,context);
115     return DD_OK;
116 }
117
118 HRESULT WINAPI IDirect3DImpl_CreateLight(
119     LPDIRECT3D iface, LPDIRECT3DLIGHT *lplight, IUnknown *lpunk
120 ) {
121     ICOM_THIS(IDirect3DImpl,iface);
122     FIXME("(%p)->(%p,%p): stub\n", This, lplight, lpunk);
123     return E_FAIL;
124 }
125
126 HRESULT WINAPI IDirect3DImpl_CreateMaterial(
127     LPDIRECT3D iface, LPDIRECT3DMATERIAL *lpmaterial, IUnknown *lpunk
128 ) {
129     ICOM_THIS(IDirect3DImpl,iface);
130     FIXME("(%p)->(%p,%p): stub\n", This, lpmaterial, lpunk);
131     return E_FAIL;
132 }
133
134 HRESULT WINAPI IDirect3DImpl_CreateViewport(
135     LPDIRECT3D iface, LPDIRECT3DVIEWPORT *lpviewport, IUnknown *lpunk
136 ) {
137     ICOM_THIS(IDirect3DImpl,iface);
138     FIXME("(%p)->(%p,%p): stub\n", This, lpviewport, lpunk);
139
140     return E_FAIL;
141 }
142
143 HRESULT WINAPI IDirect3DImpl_FindDevice(
144     LPDIRECT3D iface, LPD3DFINDDEVICESEARCH lpfinddevsrc,
145     LPD3DFINDDEVICERESULT lpfinddevrst)
146 {
147     ICOM_THIS(IDirect3DImpl,iface);
148     FIXME("(%p)->(%p,%p): stub\n", This, lpfinddevsrc, lpfinddevrst);
149     return DD_OK;
150 }
151
152 /* This is for checking the correctness of the prototypes/functions.
153  * Do not remove.
154  */
155 static ICOM_VTABLE(IDirect3D) WINE_UNUSED d3dvt = {
156     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
157     IDirect3DImpl_QueryInterface,
158     IDirect3DImpl_AddRef,
159     IDirect3DImpl_Release,
160     IDirect3DImpl_Initialize,
161     IDirect3DImpl_EnumDevices,
162     IDirect3DImpl_CreateLight,
163     IDirect3DImpl_CreateMaterial,
164     IDirect3DImpl_CreateViewport,
165     IDirect3DImpl_FindDevice
166 };
167
168 /*******************************************************************************
169  *                              IDirect3D2
170  */
171 HRESULT WINAPI IDirect3D2Impl_QueryInterface(
172     LPDIRECT3D2 iface,REFIID refiid,LPVOID *obj) {
173     ICOM_THIS(IDirect3D2Impl,iface);
174
175     /* FIXME: Not sure if this is correct */
176
177     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
178     if ( ( IsEqualGUID( &IID_IDirectDraw,  refiid ) ) ||
179          ( IsEqualGUID( &IID_IDirectDraw2, refiid ) ) ||
180          ( IsEqualGUID( &IID_IDirectDraw4, refiid ) ) ) {
181         *obj = This->ddraw;
182         IDirect3D2_AddRef(iface);
183
184         TRACE("  Creating IDirectDrawX interface (%p)\n", *obj);
185
186         return S_OK;
187     }
188     if ( ( IsEqualGUID( &IID_IDirect3D2, refiid ) ) ||
189          ( IsEqualGUID( &IID_IUnknown,   refiid ) ) ) {
190         *obj = This;
191         IDirect3D2_AddRef(iface);
192
193         TRACE("  Creating IDirect3D2 interface (%p)\n", *obj);
194
195         return S_OK;
196     }
197     if ( IsEqualGUID( &IID_IDirect3D, refiid ) ) {
198         IDirect3DImpl*  d3d;
199
200         d3d = HeapAlloc(GetProcessHeap(),0,sizeof(*d3d));
201         d3d->ref = 1;
202         d3d->ddraw = This->ddraw;
203         IDirect3D2_AddRef(iface);
204         ICOM_VTBL(d3d) = &d3dvt;
205         *obj = d3d;
206         TRACE("  Creating IDirect3D interface (%p)\n", *obj);
207         return S_OK;
208     }
209     FIXME("(%p):interface for IID %s NOT found!\n",This,debugstr_guid(refiid));
210     return OLE_E_ENUM_NOMORE;
211 }
212
213 ULONG WINAPI IDirect3D2Impl_AddRef(LPDIRECT3D2 iface) {
214     ICOM_THIS(IDirect3D2Impl,iface);
215     TRACE("(%p)->() incrementing from %lu.\n", This, This->ref );
216
217     return ++(This->ref);
218 }
219
220 ULONG WINAPI IDirect3D2Impl_Release(LPDIRECT3D2 iface) {
221     ICOM_THIS(IDirect3D2Impl,iface);
222     TRACE("(%p)->() decrementing from %lu.\n", This, This->ref );
223
224     if (!--(This->ref)) {
225         IDirectDraw2_Release((IDirectDraw2*)This->ddraw);
226         HeapFree(GetProcessHeap(),0,This);
227         return S_OK;
228     }
229     return This->ref;
230 }
231
232 HRESULT WINAPI IDirect3D2Impl_EnumDevices(
233     LPDIRECT3D2 iface,LPD3DENUMDEVICESCALLBACK cb, LPVOID context
234 ) {
235     ICOM_THIS(IDirect3D2Impl,iface);
236     FIXME("(%p)->(%p,%p),stub!\n",This,cb,context);
237     return DD_OK;
238 }
239
240 HRESULT WINAPI IDirect3D2Impl_CreateLight(
241     LPDIRECT3D2 iface, LPDIRECT3DLIGHT *lplight, IUnknown *lpunk
242 ) {
243     ICOM_THIS(IDirect3D2Impl,iface);
244     FIXME("(%p)->(%p,%p): stub\n", This, lplight, lpunk);
245     return E_FAIL;
246 }
247
248 HRESULT WINAPI IDirect3D2Impl_CreateMaterial(
249     LPDIRECT3D2 iface, LPDIRECT3DMATERIAL2 *lpmaterial, IUnknown *lpunk
250 ) {
251     ICOM_THIS(IDirect3D2Impl,iface);
252     FIXME("(%p)->(%p,%p): stub\n", This, lpmaterial, lpunk);
253     return E_FAIL;
254 }
255
256 HRESULT WINAPI IDirect3D2Impl_CreateViewport(
257     LPDIRECT3D2 iface, LPDIRECT3DVIEWPORT2 *lpviewport, IUnknown *lpunk
258 ) {
259     ICOM_THIS(IDirect3D2Impl,iface);
260     FIXME("(%p)->(%p,%p): stub\n", This, lpviewport, lpunk);
261     return E_FAIL;
262 }
263
264 HRESULT WINAPI IDirect3D2Impl_FindDevice(
265     LPDIRECT3D2 iface, LPD3DFINDDEVICESEARCH lpfinddevsrc,
266     LPD3DFINDDEVICERESULT lpfinddevrst)
267 {
268     ICOM_THIS(IDirect3D2Impl,iface);
269     FIXME("(%p)->(%p,%p): stub\n", This, lpfinddevsrc, lpfinddevrst);
270     return DD_OK;
271 }
272
273 HRESULT WINAPI IDirect3D2Impl_CreateDevice(
274     LPDIRECT3D2 iface, REFCLSID rguid, LPDIRECTDRAWSURFACE surface,
275     LPDIRECT3DDEVICE2 *device)
276 {
277     ICOM_THIS(IDirect3D2Impl,iface);
278     FIXME("(%p)->(%s,%p,%p): stub\n",This,debugstr_guid(rguid),surface,device);
279     return DDERR_INVALIDPARAMS;
280 }
281
282 /* This is for checking the correctness of the prototypes/functions.
283  * Do not remove.
284  */
285 static ICOM_VTABLE(IDirect3D2) WINE_UNUSED d3d2vt =
286 {
287     ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
288     IDirect3D2Impl_QueryInterface,
289     IDirect3D2Impl_AddRef,
290     IDirect3D2Impl_Release,
291     IDirect3D2Impl_EnumDevices,
292     IDirect3D2Impl_CreateLight,
293     IDirect3D2Impl_CreateMaterial,
294     IDirect3D2Impl_CreateViewport,
295     IDirect3D2Impl_FindDevice,
296     IDirect3D2Impl_CreateDevice
297 };