1 /* Direct3D private include file
2 * Copyright (c) 1998 Lionel ULMER
4 * This file contains all the structure that are not exported
5 * through d3d.h and all common macros.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef __GRAPHICS_WINE_D3D_PRIVATE_H
23 #define __GRAPHICS_WINE_D3D_PRIVATE_H
25 /* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */
34 #define MAX_TEXTURES 8
37 #define HIGHEST_RENDER_STATE 152
38 #define HIGHEST_TEXTURE_STAGE_STATE 24
40 /*****************************************************************************
41 * Predeclare the interface implementation structures
43 typedef struct IDirect3DLightImpl IDirect3DLightImpl
;
44 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl
;
45 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl
;
46 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl
;
47 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl
;
49 #include "ddraw_private.h"
51 typedef struct STATEBLOCKFLAGS
{
52 BOOL render_state
[HIGHEST_RENDER_STATE
];
53 BOOL texture_stage_state
[MAX_TEXTURES
][HIGHEST_TEXTURE_STAGE_STATE
];
56 typedef struct STATEBLOCK
{
57 STATEBLOCKFLAGS set_flags
;
58 DWORD render_state
[HIGHEST_RENDER_STATE
];
59 DWORD texture_stage_state
[MAX_TEXTURES
][HIGHEST_TEXTURE_STAGE_STATE
];
63 /*****************************************************************************
64 * IDirect3DLight implementation structure
66 struct IDirect3DLightImpl
68 ICOM_VFIELD_MULTI(IDirect3DLight
);
70 /* IDirect3DLight fields */
72 /* If this light is active for one viewport, put the viewport here */
73 IDirect3DViewportImpl
*active_viewport
;
80 /* Chained list used for adding / removing from viewports */
81 IDirect3DLightImpl
*next
;
83 /* Activation function */
84 void (*activate
)(IDirect3DLightImpl
*);
85 void (*desactivate
)(IDirect3DLightImpl
*);
86 void (*update
)(IDirect3DLightImpl
*);
89 /*****************************************************************************
90 * IDirect3DMaterial implementation structure
92 struct IDirect3DMaterialImpl
94 ICOM_VFIELD_MULTI(IDirect3DMaterial3
);
95 ICOM_VFIELD_MULTI(IDirect3DMaterial2
);
96 ICOM_VFIELD_MULTI(IDirect3DMaterial
);
98 /* IDirect3DMaterial2 fields */
100 IDirect3DDeviceImpl
*active_device
;
104 void (*activate
)(IDirect3DMaterialImpl
* this);
107 /*****************************************************************************
108 * IDirect3DViewport implementation structure
110 struct IDirect3DViewportImpl
112 ICOM_VFIELD_MULTI(IDirect3DViewport3
);
114 /* IDirect3DViewport fields */
115 IDirectDrawImpl
*d3d
;
116 /* If this viewport is active for one device, put the device here */
117 IDirect3DDeviceImpl
*active_device
;
128 /* Activation function */
129 void (*activate
)(IDirect3DViewportImpl
*);
131 /* Field used to chain viewports together */
132 IDirect3DViewportImpl
*next
;
135 IDirect3DLightImpl
*lights
;
137 /* Background material */
138 IDirect3DMaterialImpl
*background
;
141 /*****************************************************************************
142 * IDirect3DExecuteBuffer implementation structure
144 struct IDirect3DExecuteBufferImpl
146 ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer
);
148 /* IDirect3DExecuteBuffer fields */
149 IDirectDrawImpl
*d3d
;
150 IDirect3DDeviceImpl
* d3ddev
;
152 D3DEXECUTEBUFFERDESC desc
;
155 /* This buffer will store the transformed vertices */
160 /* This flags is set to TRUE if we allocated ourselves the
164 void (*execute
)(IDirect3DExecuteBufferImpl
* this,
165 IDirect3DDeviceImpl
* dev
,
166 IDirect3DViewportImpl
* vp
);
169 /* Internal structure to store the state of the clipping planes */
170 typedef struct d3d7clippingplane
175 /*****************************************************************************
176 * IDirect3DDevice implementation structure
179 #define WORLDMAT_CHANGED (0x00000001 << 0)
180 #define VIEWMAT_CHANGED (0x00000001 << 1)
181 #define PROJMAT_CHANGED (0x00000001 << 2)
182 #define TEXMAT0_CHANGED (0x00000001 << 3)
183 #define TEXMAT1_CHANGED (0x00000001 << 4)
184 #define TEXMAT2_CHANGED (0x00000001 << 5)
185 #define TEXMAT3_CHANGED (0x00000001 << 6)
186 #define TEXMAT4_CHANGED (0x00000001 << 7)
187 #define TEXMAT5_CHANGED (0x00000001 << 8)
188 #define TEXMAT6_CHANGED (0x00000001 << 9)
189 #define TEXMAT7_CHANGED (0x00000001 << 10)
191 struct IDirect3DDeviceImpl
193 ICOM_VFIELD_MULTI(IDirect3DDevice7
);
194 ICOM_VFIELD_MULTI(IDirect3DDevice3
);
195 ICOM_VFIELD_MULTI(IDirect3DDevice2
);
196 ICOM_VFIELD_MULTI(IDirect3DDevice
);
198 /* IDirect3DDevice fields */
199 IDirectDrawImpl
*d3d
;
200 IDirectDrawSurfaceImpl
*surface
;
202 IDirect3DViewportImpl
*viewport_list
;
203 IDirect3DViewportImpl
*current_viewport
;
204 D3DVIEWPORT7 active_viewport
;
206 IDirectDrawSurfaceImpl
*current_texture
[MAX_TEXTURES
];
207 IDirectDrawSurfaceImpl
*current_zbuffer
;
209 /* Current transformation matrices */
210 D3DMATRIX
*world_mat
;
213 D3DMATRIX
*tex_mat
[MAX_TEXTURES
];
214 BOOLEAN tex_mat_is_identity
[MAX_TEXTURES
];
216 /* Current material used in D3D7 mode */
217 D3DMATERIAL7 current_material
;
219 /* Light parameters */
220 DWORD active_lights
, set_lights
;
221 D3DLIGHT7 light_parameters
[MAX_LIGHTS
];
223 /* clipping planes */
224 DWORD max_clipping_planes
;
225 d3d7clippingplane
*clipping_planes
;
227 void (*set_context
)(IDirect3DDeviceImpl
*);
228 HRESULT (*clear
)(IDirect3DDeviceImpl
*This
,
235 void (*matrices_updated
)(IDirect3DDeviceImpl
*This
, DWORD matrices
);
236 void (*set_matrices
)(IDirect3DDeviceImpl
*This
, DWORD matrices
,
237 D3DMATRIX
*world_mat
, D3DMATRIX
*view_mat
, D3DMATRIX
*proj_mat
);
238 void (*flush_to_framebuffer
)(IDirect3DDeviceImpl
*This
, LPCRECT pRect
, IDirectDrawSurfaceImpl
*surf
);
240 STATEBLOCK state_block
;
242 /* Used to prevent locks and rendering to overlap */
243 CRITICAL_SECTION crit
;
246 /*****************************************************************************
247 * IDirect3DVertexBuffer implementation structure
249 struct IDirect3DVertexBufferImpl
251 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7
);
252 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer
);
254 IDirectDrawImpl
*d3d
;
255 D3DVERTEXBUFFERDESC desc
;
257 DWORD vertex_buffer_size
;
262 /* Various dump and helper functions */
263 extern const char *_get_renderstate(D3DRENDERSTATETYPE type
);
264 extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat
);
265 extern void dump_D3DCOLORVALUE(D3DCOLORVALUE
*lpCol
);
266 extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight
);
267 extern void dump_DPFLAGS(DWORD dwFlags
);
268 extern void dump_D3DMATRIX(D3DMATRIX
*mat
);
269 extern void dump_D3DVECTOR(D3DVECTOR
*lpVec
);
270 extern void dump_flexible_vertex(DWORD d3dvtVertexType
);
271 extern DWORD
get_flexible_vertex_size(DWORD d3dvtVertexType
);
272 extern void convert_FVF_to_strided_data(DWORD d3dvtVertexType
, LPVOID lpvVertices
, D3DDRAWPRIMITIVESTRIDEDDATA
*strided
, DWORD dwStartVertex
);
273 extern void dump_D3DVOP(DWORD dwVertexOp
);
274 extern void dump_D3DPV(DWORD dwFlags
);
275 extern void multiply_matrix(LPD3DMATRIX
,LPD3DMATRIX
,LPD3DMATRIX
);
277 extern const float id_mat
[16];
279 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */