1 /* Direct3D private include file
2 * Copyright (c) 1998-2004 Lionel ULMER
3 * Copyright (c) 2002-2004 Christian Costa
5 * This file contains all the structure that are not exported
6 * through d3d.h and all common macros.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef __GRAPHICS_WINE_D3D_PRIVATE_H
24 #define __GRAPHICS_WINE_D3D_PRIVATE_H
26 /* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */
35 #define MAX_TEXTURES 8
38 #define HIGHEST_RENDER_STATE 152
39 #define HIGHEST_TEXTURE_STAGE_STATE 24
41 /*****************************************************************************
42 * Predeclare the interface implementation structures
44 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
45 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
46 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
47 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
48 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
50 #include "ddraw_private.h"
52 typedef struct STATEBLOCKFLAGS {
53 BOOL render_state[HIGHEST_RENDER_STATE];
54 BOOL texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE];
57 typedef struct STATEBLOCK {
58 STATEBLOCKFLAGS set_flags;
59 DWORD render_state[HIGHEST_RENDER_STATE];
60 DWORD texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE];
64 /*****************************************************************************
65 * IDirect3DLight implementation structure
67 struct IDirect3DLightImpl
69 ICOM_VFIELD_MULTI(IDirect3DLight);
71 /* IDirect3DLight fields */
73 /* If this light is active for one viewport, put the viewport here */
74 IDirect3DViewportImpl *active_viewport;
81 /* Chained list used for adding / removing from viewports */
82 IDirect3DLightImpl *next;
84 /* Activation function */
85 void (*activate)(IDirect3DLightImpl*);
86 void (*desactivate)(IDirect3DLightImpl*);
87 void (*update)(IDirect3DLightImpl*);
90 /*****************************************************************************
91 * IDirect3DMaterial implementation structure
93 struct IDirect3DMaterialImpl
95 ICOM_VFIELD_MULTI(IDirect3DMaterial3);
96 ICOM_VFIELD_MULTI(IDirect3DMaterial2);
97 ICOM_VFIELD_MULTI(IDirect3DMaterial);
99 /* IDirect3DMaterial2 fields */
100 IDirectDrawImpl *d3d;
101 IDirect3DDeviceImpl *active_device;
105 void (*activate)(IDirect3DMaterialImpl* this);
108 /*****************************************************************************
109 * IDirect3DViewport implementation structure
111 struct IDirect3DViewportImpl
113 ICOM_VFIELD_MULTI(IDirect3DViewport3);
115 /* IDirect3DViewport fields */
116 IDirectDrawImpl *d3d;
117 /* If this viewport is active for one device, put the device here */
118 IDirect3DDeviceImpl *active_device;
129 /* Activation function */
130 void (*activate)(IDirect3DViewportImpl*);
132 /* Field used to chain viewports together */
133 IDirect3DViewportImpl *next;
136 IDirect3DLightImpl *lights;
138 /* Background material */
139 IDirect3DMaterialImpl *background;
142 /*****************************************************************************
143 * IDirect3DExecuteBuffer implementation structure
145 struct IDirect3DExecuteBufferImpl
147 ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
149 /* IDirect3DExecuteBuffer fields */
150 IDirectDrawImpl *d3d;
151 IDirect3DDeviceImpl* d3ddev;
153 D3DEXECUTEBUFFERDESC desc;
156 /* This buffer will store the transformed vertices */
161 /* This flags is set to TRUE if we allocated ourselves the
165 void (*execute)(IDirect3DExecuteBufferImpl* this,
166 IDirect3DDeviceImpl* dev,
167 IDirect3DViewportImpl* vp);
170 /* Internal structure to store the state of the clipping planes */
171 typedef struct d3d7clippingplane
176 /*****************************************************************************
177 * IDirect3DDevice implementation structure
180 #define WORLDMAT_CHANGED (0x00000001 << 0)
181 #define VIEWMAT_CHANGED (0x00000001 << 1)
182 #define PROJMAT_CHANGED (0x00000001 << 2)
183 #define TEXMAT0_CHANGED (0x00000001 << 3)
184 #define TEXMAT1_CHANGED (0x00000001 << 4)
185 #define TEXMAT2_CHANGED (0x00000001 << 5)
186 #define TEXMAT3_CHANGED (0x00000001 << 6)
187 #define TEXMAT4_CHANGED (0x00000001 << 7)
188 #define TEXMAT5_CHANGED (0x00000001 << 8)
189 #define TEXMAT6_CHANGED (0x00000001 << 9)
190 #define TEXMAT7_CHANGED (0x00000001 << 10)
192 struct IDirect3DDeviceImpl
194 ICOM_VFIELD_MULTI(IDirect3DDevice7);
195 ICOM_VFIELD_MULTI(IDirect3DDevice3);
196 ICOM_VFIELD_MULTI(IDirect3DDevice2);
197 ICOM_VFIELD_MULTI(IDirect3DDevice);
200 /* Version of the Direct3D object from which the device has been created */
203 /* IDirect3DDevice fields */
204 IDirectDrawImpl *d3d;
205 IDirectDrawSurfaceImpl *surface;
207 IDirect3DViewportImpl *viewport_list;
208 IDirect3DViewportImpl *current_viewport;
209 D3DVIEWPORT7 active_viewport;
211 IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
212 IDirectDrawSurfaceImpl *current_zbuffer;
214 /* Current transformation matrices */
215 D3DMATRIX *world_mat;
218 D3DMATRIX *tex_mat[MAX_TEXTURES];
219 BOOLEAN tex_mat_is_identity[MAX_TEXTURES];
221 /* Current material used in D3D7 mode */
222 D3DMATERIAL7 current_material;
227 /* Light parameters */
228 DWORD active_lights, set_lights;
229 D3DLIGHT7 light_parameters[MAX_LIGHTS];
231 /* clipping planes */
232 DWORD max_clipping_planes;
233 d3d7clippingplane *clipping_planes;
235 void (*set_context)(IDirect3DDeviceImpl*);
236 HRESULT (*clear)(IDirect3DDeviceImpl *This,
243 void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
244 void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
245 D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
246 void (*flush_to_framebuffer)(IDirect3DDeviceImpl *This, LPCRECT pRect, IDirectDrawSurfaceImpl *surf);
248 STATEBLOCK state_block;
250 /* Used to prevent locks and rendering to overlap */
251 CRITICAL_SECTION crit;
254 /*****************************************************************************
255 * IDirect3DVertexBuffer implementation structure
257 struct IDirect3DVertexBufferImpl
259 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
260 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
262 IDirectDrawImpl *d3d;
263 D3DVERTEXBUFFERDESC desc;
265 DWORD vertex_buffer_size;
270 /* Various dump and helper functions */
271 extern const char *_get_renderstate(D3DRENDERSTATETYPE type);
272 extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat);
273 extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol);
274 extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight);
275 extern void dump_DPFLAGS(DWORD dwFlags);
276 extern void dump_D3DMATRIX(D3DMATRIX *mat);
277 extern void dump_D3DVECTOR(D3DVECTOR *lpVec);
278 extern void dump_flexible_vertex(DWORD d3dvtVertexType);
279 extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
280 extern void convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided, DWORD dwStartVertex);
281 extern void dump_D3DVOP(DWORD dwVertexOp);
282 extern void dump_D3DPV(DWORD dwFlags);
283 extern void multiply_matrix(LPD3DMATRIX,LPD3DMATRIX,LPD3DMATRIX);
285 extern const float id_mat[16];
287 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */