offsets array is the size of the wine data format so there is no need
[wine.git] / dlls / ddraw / d3d_private.h
blob284ce9215af1bc0900890af7c8973ca08ef5113b
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 */
28 #include <stdarg.h>
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "d3d.h"
35 #define MAX_TEXTURES 8
36 #define MAX_LIGHTS 16
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];
55 } STATEBLOCKFLAGS;
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];
61 } STATEBLOCK;
64 /*****************************************************************************
65 * IDirect3DLight implementation structure
67 struct IDirect3DLightImpl
69 ICOM_VFIELD_MULTI(IDirect3DLight);
70 DWORD ref;
71 /* IDirect3DLight fields */
72 IDirectDrawImpl *d3d;
73 /* If this light is active for one viewport, put the viewport here */
74 IDirect3DViewportImpl *active_viewport;
76 D3DLIGHT2 light;
77 D3DLIGHT7 light7;
79 DWORD dwLightIndex;
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);
98 DWORD ref;
99 /* IDirect3DMaterial2 fields */
100 IDirectDrawImpl *d3d;
101 IDirect3DDeviceImpl *active_device;
103 D3DMATERIAL mat;
105 void (*activate)(IDirect3DMaterialImpl* this);
108 /*****************************************************************************
109 * IDirect3DViewport implementation structure
111 struct IDirect3DViewportImpl
113 ICOM_VFIELD_MULTI(IDirect3DViewport3);
114 DWORD ref;
115 /* IDirect3DViewport fields */
116 IDirectDrawImpl *d3d;
117 /* If this viewport is active for one device, put the device here */
118 IDirect3DDeviceImpl *active_device;
120 DWORD num_lights;
121 DWORD map_lights;
123 int use_vp2;
124 union {
125 D3DVIEWPORT vp1;
126 D3DVIEWPORT2 vp2;
127 } viewports;
129 /* Activation function */
130 void (*activate)(IDirect3DViewportImpl*);
132 /* Field used to chain viewports together */
133 IDirect3DViewportImpl *next;
135 /* Lights list */
136 IDirect3DLightImpl *lights;
138 /* Background material */
139 IDirect3DMaterialImpl *background;
142 /*****************************************************************************
143 * IDirect3DExecuteBuffer implementation structure
145 struct IDirect3DExecuteBufferImpl
147 ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
148 DWORD ref;
149 /* IDirect3DExecuteBuffer fields */
150 IDirectDrawImpl *d3d;
151 IDirect3DDeviceImpl* d3ddev;
153 D3DEXECUTEBUFFERDESC desc;
154 D3DEXECUTEDATA data;
156 /* This buffer will store the transformed vertices */
157 void* vertex_data;
158 WORD* indices;
159 int nb_indices;
161 /* This flags is set to TRUE if we allocated ourselves the
162 data buffer */
163 BOOL need_free;
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
173 D3DVALUE plane[4];
174 } 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);
198 DWORD ref;
200 /* IDirect3DDevice fields */
201 IDirectDrawImpl *d3d;
202 IDirectDrawSurfaceImpl *surface;
204 IDirect3DViewportImpl *viewport_list;
205 IDirect3DViewportImpl *current_viewport;
206 D3DVIEWPORT7 active_viewport;
208 IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
209 IDirectDrawSurfaceImpl *current_zbuffer;
211 /* Current transformation matrices */
212 D3DMATRIX *world_mat;
213 D3DMATRIX *view_mat;
214 D3DMATRIX *proj_mat;
215 D3DMATRIX *tex_mat[MAX_TEXTURES];
216 BOOLEAN tex_mat_is_identity[MAX_TEXTURES];
218 /* Current material used in D3D7 mode */
219 D3DMATERIAL7 current_material;
221 /* Light state */
222 DWORD material;
224 /* Light parameters */
225 DWORD active_lights, set_lights;
226 D3DLIGHT7 light_parameters[MAX_LIGHTS];
228 /* clipping planes */
229 DWORD max_clipping_planes;
230 d3d7clippingplane *clipping_planes;
232 void (*set_context)(IDirect3DDeviceImpl*);
233 HRESULT (*clear)(IDirect3DDeviceImpl *This,
234 DWORD dwCount,
235 LPD3DRECT lpRects,
236 DWORD dwFlags,
237 DWORD dwColor,
238 D3DVALUE dvZ,
239 DWORD dwStencil);
240 void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
241 void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
242 D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
243 void (*flush_to_framebuffer)(IDirect3DDeviceImpl *This, LPCRECT pRect, IDirectDrawSurfaceImpl *surf);
245 STATEBLOCK state_block;
247 /* Used to prevent locks and rendering to overlap */
248 CRITICAL_SECTION crit;
251 /*****************************************************************************
252 * IDirect3DVertexBuffer implementation structure
254 struct IDirect3DVertexBufferImpl
256 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
257 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
258 DWORD ref;
259 IDirectDrawImpl *d3d;
260 D3DVERTEXBUFFERDESC desc;
261 LPVOID *vertices;
262 DWORD vertex_buffer_size;
264 BOOLEAN processed;
267 /* Various dump and helper functions */
268 extern const char *_get_renderstate(D3DRENDERSTATETYPE type);
269 extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat);
270 extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol);
271 extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight);
272 extern void dump_DPFLAGS(DWORD dwFlags);
273 extern void dump_D3DMATRIX(D3DMATRIX *mat);
274 extern void dump_D3DVECTOR(D3DVECTOR *lpVec);
275 extern void dump_flexible_vertex(DWORD d3dvtVertexType);
276 extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
277 extern void convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided, DWORD dwStartVertex);
278 extern void dump_D3DVOP(DWORD dwVertexOp);
279 extern void dump_D3DPV(DWORD dwFlags);
280 extern void multiply_matrix(LPD3DMATRIX,LPD3DMATRIX,LPD3DMATRIX);
282 extern const float id_mat[16];
284 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */