1 /* Direct3D private include file
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
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
38 ICOM_VFIELD(IDirect3D
);
40 /* IDirect3D fields */
41 IDirectDrawImpl
* ddraw
;
44 /*****************************************************************************
45 * IDirect3D2 implementation structure
50 ICOM_VFIELD(IDirect3D2
);
52 /* IDirect3D2 fields */
53 IDirectDrawImpl
* ddraw
;
56 /*****************************************************************************
57 * IDirect3DLight implementation structure
59 struct IDirect3DLightImpl
62 ICOM_VFIELD(IDirect3DLight
);
64 /* IDirect3DLight fields */
73 /* Chained list used for adding / removing from viewports */
74 IDirect3DLightImpl
*next
, *prev
;
76 /* Activation function */
77 void (*activate
)(IDirect3DLightImpl
*);
80 /* Awful OpenGL code !!! */
86 /*****************************************************************************
87 * IDirect3DMaterial2 implementation structure
89 struct IDirect3DMaterial2Impl
92 ICOM_VFIELD(IDirect3DMaterial2
);
94 /* IDirect3DMaterial2 fields */
100 IDirect3DDeviceImpl
* active_device1
;
101 IDirect3DDevice2Impl
* active_device2
;
107 void (*activate
)(IDirect3DMaterial2Impl
* this);
110 /*****************************************************************************
111 * IDirect3DTexture2 implementation structure
113 struct IDirect3DTexture2Impl
115 /* IUnknown fields */
116 ICOM_VFIELD(IDirect3DTexture2
);
118 /* IDirect3DTexture2 fields */
119 void* D3Ddevice
; /* I put (void *) to use the same pointer for both
120 Direct3D and Direct3D2 */
124 IDirectDrawSurface4Impl
* surface
;
127 /*****************************************************************************
128 * IDirect3DViewport2 implementation structure
130 struct IDirect3DViewport2Impl
132 /* IUnknown fields */
133 ICOM_VFIELD(IDirect3DViewport2
);
135 /* IDirect3DViewport2 fields */
138 IDirect3D2Impl
* d3d2
;
140 /* If this viewport is active for one device, put the device here */
142 IDirect3DDeviceImpl
* active_device1
;
143 IDirect3DDevice2Impl
* active_device2
;
153 /* Activation function */
154 void (*activate
)(IDirect3DViewport2Impl
*);
156 /* Field used to chain viewports together */
157 IDirect3DViewport2Impl
* next
;
160 IDirect3DLightImpl
* lights
;
168 /*****************************************************************************
169 * IDirect3DExecuteBuffer implementation structure
171 struct IDirect3DExecuteBufferImpl
173 /* IUnknown fields */
174 ICOM_VFIELD(IDirect3DExecuteBuffer
);
176 /* IDirect3DExecuteBuffer fields */
177 IDirect3DDeviceImpl
* d3ddev
;
179 D3DEXECUTEBUFFERDESC desc
;
182 /* This buffer will store the transformed vertices */
184 D3DVERTEXTYPE vertex_type
;
186 /* This flags is set to TRUE if we allocated ourselves the
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
);
203 /* IDirect3DDevice fields */
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
);
221 /* IDirect3DDevice fields */
223 IDirectDrawSurfaceImpl
* surface
;
225 IDirect3DViewport2Impl
* viewport_list
;
226 IDirect3DViewport2Impl
* current_viewport
;
228 void (*set_context
)(IDirect3DDevice2Impl
*);
239 #define LEAVE_GL() LeaveCriticalSection( &X11DRV_CritSection )
240 #define ENTER_GL() EnterCriticalSection( &X11DRV_CritSection )
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 */
287 /* This is used for textures */
291 typedef struct OpenGL_IDirect3DDevice2
{
292 IDirect3DDevice2Impl common
;
294 /* These are the OpenGL-specific variables */
297 unsigned char *buffer
;
302 /* The current render state */
305 /* The last type of vertex drawn */
311 } OpenGL_IDirect3DDevice2
;
313 typedef struct OpenGL_IDirect3DDevice
{
314 IDirect3DDeviceImpl common
;
316 /* These are the OpenGL-specific variables */
319 unsigned char *buffer
;
324 /* The current render state */
327 D3DMATRIX
*world_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 */