Added prototypes for registry functions.
[wine/hacks.git] / graphics / d3d_private.h
blob8ac67cc4fb5b6eb2913fcd5862b681916e35e346
1 /* Direct3D private include file
2 (c) 1998 Lionel ULMER
4 This files contains all the structure that are not exported
5 through d3d.h and all common macros. */
7 #ifndef __GRAPHICS_WINE_D3D_PRIVATE_H
8 #define __GRAPHICS_WINE_D3D_PRIVATE_H
10 #include "wine_gl.h"
11 #include "d3d.h"
13 #include "x11drv.h"
15 #undef USE_OSMESA
17 /*****************************************************************************
18 * Predeclare the interface implementation structures
20 typedef struct IDirect3DImpl IDirect3DImpl;
21 typedef struct IDirect3D2Impl IDirect3D2Impl;
22 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
23 typedef struct IDirect3DMaterial2Impl IDirect3DMaterial2Impl;
24 typedef struct IDirect3DTexture2Impl IDirect3DTexture2Impl;
25 typedef struct IDirect3DViewport2Impl IDirect3DViewport2Impl;
26 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
27 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
28 typedef struct IDirect3DDevice2Impl IDirect3DDevice2Impl;
30 #include "ddraw_private.h"
32 /*****************************************************************************
33 * IDirect3D implementation structure
35 struct IDirect3DImpl
37 /* IUnknown fields */
38 ICOM_VFIELD(IDirect3D);
39 DWORD ref;
40 /* IDirect3D fields */
41 IDirectDrawImpl* ddraw;
44 /*****************************************************************************
45 * IDirect3D2 implementation structure
47 struct IDirect3D2Impl
49 /* IUnknown fields */
50 ICOM_VFIELD(IDirect3D2);
51 DWORD ref;
52 /* IDirect3D2 fields */
53 IDirectDrawImpl* ddraw;
56 /*****************************************************************************
57 * IDirect3DLight implementation structure
59 struct IDirect3DLightImpl
61 /* IUnknown fields */
62 ICOM_VFIELD(IDirect3DLight);
63 DWORD ref;
64 /* IDirect3DLight fields */
65 union {
66 IDirect3DImpl* d3d1;
67 IDirect3D2Impl* d3d2;
68 } d3d;
69 int type;
71 D3DLIGHT2 light;
73 /* Chained list used for adding / removing from viewports */
74 IDirect3DLightImpl *next, *prev;
76 /* Activation function */
77 void (*activate)(IDirect3DLightImpl*);
78 int is_active;
80 /* Awful OpenGL code !!! */
81 #ifdef HAVE_MESAGL
82 GLenum light_num;
83 #endif
86 /*****************************************************************************
87 * IDirect3DMaterial2 implementation structure
89 struct IDirect3DMaterial2Impl
91 /* IUnknown fields */
92 ICOM_VFIELD(IDirect3DMaterial2);
93 DWORD ref;
94 /* IDirect3DMaterial2 fields */
95 union {
96 IDirect3DImpl* d3d1;
97 IDirect3D2Impl* d3d2;
98 } d3d;
99 union {
100 IDirect3DDeviceImpl* active_device1;
101 IDirect3DDevice2Impl* active_device2;
102 } device;
103 int use_d3d2;
105 D3DMATERIAL mat;
107 void (*activate)(IDirect3DMaterial2Impl* this);
110 /*****************************************************************************
111 * IDirect3DTexture2 implementation structure
113 struct IDirect3DTexture2Impl
115 /* IUnknown fields */
116 ICOM_VFIELD(IDirect3DTexture2);
117 DWORD ref;
118 /* IDirect3DTexture2 fields */
119 void* D3Ddevice; /* I put (void *) to use the same pointer for both
120 Direct3D and Direct3D2 */
121 #ifdef HAVE_MESAGL
122 GLuint tex_name;
123 #endif
124 IDirectDrawSurface4Impl* surface;
127 /*****************************************************************************
128 * IDirect3DViewport2 implementation structure
130 struct IDirect3DViewport2Impl
132 /* IUnknown fields */
133 ICOM_VFIELD(IDirect3DViewport2);
134 DWORD ref;
135 /* IDirect3DViewport2 fields */
136 union {
137 IDirect3DImpl* d3d1;
138 IDirect3D2Impl* d3d2;
139 } d3d;
140 /* If this viewport is active for one device, put the device here */
141 union {
142 IDirect3DDeviceImpl* active_device1;
143 IDirect3DDevice2Impl* active_device2;
144 } device;
145 int use_d3d2;
147 union {
148 D3DVIEWPORT vp1;
149 D3DVIEWPORT2 vp2;
150 } viewport;
151 int use_vp2;
153 /* Activation function */
154 void (*activate)(IDirect3DViewport2Impl*);
156 /* Field used to chain viewports together */
157 IDirect3DViewport2Impl* next;
159 /* Lights list */
160 IDirect3DLightImpl* lights;
162 /* OpenGL code */
163 #ifdef HAVE_MESAGL
164 GLenum nextlight;
165 #endif
168 /*****************************************************************************
169 * IDirect3DExecuteBuffer implementation structure
171 struct IDirect3DExecuteBufferImpl
173 /* IUnknown fields */
174 ICOM_VFIELD(IDirect3DExecuteBuffer);
175 DWORD ref;
176 /* IDirect3DExecuteBuffer fields */
177 IDirect3DDeviceImpl* d3ddev;
179 D3DEXECUTEBUFFERDESC desc;
180 D3DEXECUTEDATA data;
182 /* This buffer will store the transformed vertices */
183 void* vertex_data;
184 D3DVERTEXTYPE vertex_type;
186 /* This flags is set to TRUE if we allocated ourselves the
187 data buffer */
188 BOOL need_free;
190 void (*execute)(IDirect3DExecuteBuffer* this,
191 IDirect3DDevice* dev,
192 IDirect3DViewport2* vp);
195 /*****************************************************************************
196 * IDirect3DDevice implementation structure
198 struct IDirect3DDeviceImpl
200 /* IUnknown fields */
201 ICOM_VFIELD(IDirect3DDevice);
202 DWORD ref;
203 /* IDirect3DDevice fields */
204 IDirect3DImpl* d3d;
205 IDirectDrawSurfaceImpl* surface;
207 IDirect3DViewport2Impl* viewport_list;
208 IDirect3DViewport2Impl* current_viewport;
210 void (*set_context)(IDirect3DDeviceImpl*);
213 /*****************************************************************************
214 * IDirect3DDevice2 implementation structure
216 struct IDirect3DDevice2Impl
218 /* IUnknown fields */
219 ICOM_VFIELD(IDirect3DDevice2);
220 DWORD ref;
221 /* IDirect3DDevice fields */
222 IDirect3D2Impl* d3d;
223 IDirectDrawSurfaceImpl* surface;
225 IDirect3DViewport2Impl* viewport_list;
226 IDirect3DViewport2Impl* current_viewport;
228 void (*set_context)(IDirect3DDevice2Impl*);
233 #ifdef HAVE_MESAGL
235 #ifdef USE_OSMESA
236 #define LEAVE_GL() ;
237 #define ENTER_GL() ;
238 #else
239 #define LEAVE_GL() LeaveCriticalSection( &X11DRV_CritSection )
240 #define ENTER_GL() EnterCriticalSection( &X11DRV_CritSection )
241 #endif
243 /* Matrix copy WITH transposition */
244 #define conv_mat2(mat,gl_mat) \
246 TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
247 TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
248 TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
249 TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44); \
250 (gl_mat)[ 0] = (mat)->_11; \
251 (gl_mat)[ 1] = (mat)->_21; \
252 (gl_mat)[ 2] = (mat)->_31; \
253 (gl_mat)[ 3] = (mat)->_41; \
254 (gl_mat)[ 4] = (mat)->_12; \
255 (gl_mat)[ 5] = (mat)->_22; \
256 (gl_mat)[ 6] = (mat)->_32; \
257 (gl_mat)[ 7] = (mat)->_42; \
258 (gl_mat)[ 8] = (mat)->_13; \
259 (gl_mat)[ 9] = (mat)->_23; \
260 (gl_mat)[10] = (mat)->_33; \
261 (gl_mat)[11] = (mat)->_43; \
262 (gl_mat)[12] = (mat)->_14; \
263 (gl_mat)[13] = (mat)->_24; \
264 (gl_mat)[14] = (mat)->_34; \
265 (gl_mat)[15] = (mat)->_44; \
268 /* Matrix copy WITHOUT transposition */
269 #define conv_mat(mat,gl_mat) \
271 TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
272 TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
273 TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
274 TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44); \
275 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
278 #define dump_mat(mat) \
279 TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
280 TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
281 TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
282 TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44);
284 typedef struct render_state {
285 /* This is used for the device mode */
286 GLenum src, dst;
287 /* This is used for textures */
288 GLenum mag, min;
289 } RenderState;
291 typedef struct OpenGL_IDirect3DDevice2 {
292 IDirect3DDevice2Impl common;
294 /* These are the OpenGL-specific variables */
295 #ifdef USE_OSMESA
296 OSMesaContext ctx;
297 unsigned char *buffer;
298 #else
299 GLXContext ctx;
300 #endif
302 /* The current render state */
303 RenderState rs;
305 /* The last type of vertex drawn */
306 D3DVERTEXTYPE vt;
308 float world_mat[16];
309 float view_mat[16];
310 float proj_mat[16];
311 } OpenGL_IDirect3DDevice2;
313 typedef struct OpenGL_IDirect3DDevice {
314 IDirect3DDeviceImpl common;
316 /* These are the OpenGL-specific variables */
317 #ifdef USE_OSMESA
318 OSMesaContext ctx;
319 unsigned char *buffer;
320 #else
321 GLXContext ctx;
322 #endif
324 /* The current render state */
325 RenderState rs;
327 D3DMATRIX *world_mat;
328 D3DMATRIX *view_mat;
329 D3DMATRIX *proj_mat;
330 } OpenGL_IDirect3DDevice;
332 #define _dump_colorvalue(s,v) \
333 TRACE(" " s " : %f %f %f %f\n", \
334 (v).r.r, (v).g.g, (v).b.b, (v).a.a);
336 /* Common functions defined in d3dcommon.c */
337 void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
338 DWORD dwRenderState, RenderState *rs) ;
340 #endif /* HAVE_MESAGL */
342 /* All non-static functions 'exported' by various sub-objects */
343 extern LPDIRECT3DTEXTURE2 d3dtexture2_create(IDirectDrawSurface4Impl* surf);
344 extern LPDIRECT3DTEXTURE d3dtexture_create(IDirectDrawSurface4Impl* surf);
346 extern LPDIRECT3DLIGHT d3dlight_create_dx3(IDirect3DImpl* d3d1);
347 extern LPDIRECT3DLIGHT d3dlight_create(IDirect3D2Impl* d3d2);
349 extern LPDIRECT3DEXECUTEBUFFER d3dexecutebuffer_create(IDirect3DDeviceImpl* d3ddev, LPD3DEXECUTEBUFFERDESC lpDesc);
351 extern LPDIRECT3DMATERIAL d3dmaterial_create(IDirect3DImpl* d3d1);
352 extern LPDIRECT3DMATERIAL2 d3dmaterial2_create(IDirect3D2Impl* d3d2);
354 extern LPDIRECT3DVIEWPORT d3dviewport_create(IDirect3DImpl* d3d1);
355 extern LPDIRECT3DVIEWPORT2 d3dviewport2_create(IDirect3D2Impl* d3d2);
357 extern int is_OpenGL_dx3(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDeviceImpl** device);
358 extern int d3d_OpenGL_dx3(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) ;
359 extern int d3d_OpenGL(LPD3DENUMDEVICESCALLBACK cb, LPVOID context) ;
360 extern int is_OpenGL(REFCLSID rguid, IDirectDrawSurfaceImpl* surface, IDirect3DDevice2Impl** device, IDirect3D2Impl* d3d);
363 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */