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 */
29 #define HIGHEST_RENDER_STATE 152
30 #define HIGHEST_TEXTURE_STAGE_STATE 24
31 #define HIGHEST_LIGHT_STATE 8
33 /*****************************************************************************
34 * Predeclare the interface implementation structures
36 typedef struct IDirect3DImpl IDirect3DImpl;
37 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
38 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
39 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
40 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
41 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
42 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
44 #include "ddraw_private.h"
46 typedef struct STATEBLOCKFLAGS {
47 BOOL render_state[HIGHEST_RENDER_STATE];
48 BOOL texture_stage_state[8][HIGHEST_TEXTURE_STAGE_STATE];
49 BOOL light_state[HIGHEST_LIGHT_STATE];
52 typedef struct STATEBLOCK {
53 STATEBLOCKFLAGS set_flags;
54 DWORD render_state[HIGHEST_RENDER_STATE];
55 DWORD texture_stage_state[8][HIGHEST_TEXTURE_STAGE_STATE];
56 DWORD light_state[HIGHEST_LIGHT_STATE];
59 /*****************************************************************************
60 * IDirect3D implementation structure.
61 * This is common for interfaces 1, 2, 3 and 7.
65 ICOM_VFIELD_MULTI(IDirect3D7);
66 ICOM_VFIELD_MULTI(IDirect3D3);
67 ICOM_VFIELD_MULTI(IDirect3D2);
68 ICOM_VFIELD_MULTI(IDirect3D);
70 /* IDirect3D fields */
71 IDirectDrawImpl* ddraw;
73 /* Used as a callback function to create a texture */
74 HRESULT (*create_texture)(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main);
76 /* Used as a callback for Devices to tell to the D3D object it's been created */
77 HRESULT (*added_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device);
78 HRESULT (*removed_device)(IDirect3DImpl *d3d, IDirect3DDeviceImpl *device);
80 /* This is needed for delayed texture creation and Z buffer blits */
81 IDirect3DDeviceImpl *current_device;
84 /*****************************************************************************
85 * IDirect3DLight implementation structure
87 struct IDirect3DLightImpl
89 ICOM_VFIELD_MULTI(IDirect3DLight);
91 /* IDirect3DLight fields */
96 /* Chained list used for adding / removing from viewports */
97 IDirect3DLightImpl *next;
99 /* Activation function */
100 void (*activate)(IDirect3DLightImpl*);
101 void (*desactivate)(IDirect3DLightImpl*);
102 void (*update)(IDirect3DLightImpl*);
105 /*****************************************************************************
106 * IDirect3DMaterial implementation structure
108 struct IDirect3DMaterialImpl
110 ICOM_VFIELD_MULTI(IDirect3DMaterial3);
111 ICOM_VFIELD_MULTI(IDirect3DMaterial2);
112 ICOM_VFIELD_MULTI(IDirect3DMaterial);
114 /* IDirect3DMaterial2 fields */
116 IDirect3DDeviceImpl *active_device;
120 void (*activate)(IDirect3DMaterialImpl* this);
123 /*****************************************************************************
124 * IDirect3DViewport implementation structure
126 struct IDirect3DViewportImpl
128 ICOM_VFIELD_MULTI(IDirect3DViewport3);
130 /* IDirect3DViewport fields */
132 /* If this viewport is active for one device, put the device here */
133 IDirect3DDeviceImpl *active_device;
141 /* Activation function */
142 void (*activate)(IDirect3DViewportImpl*);
144 /* Field used to chain viewports together */
145 IDirect3DViewportImpl *next;
148 IDirect3DLightImpl *lights;
150 /* Background material */
151 IDirect3DMaterialImpl *background;
154 /*****************************************************************************
155 * IDirect3DExecuteBuffer implementation structure
157 struct IDirect3DExecuteBufferImpl
159 ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
161 /* IDirect3DExecuteBuffer fields */
163 IDirect3DDeviceImpl* d3ddev;
165 D3DEXECUTEBUFFERDESC desc;
168 /* This buffer will store the transformed vertices */
170 D3DVERTEXTYPE vertex_type;
172 /* This flags is set to TRUE if we allocated ourselves the
176 void (*execute)(IDirect3DExecuteBufferImpl* this,
177 IDirect3DDeviceImpl* dev,
178 IDirect3DViewportImpl* vp);
181 /*****************************************************************************
182 * IDirect3DDevice implementation structure
185 #define MAX_TEXTURES 8
186 #define MAX_LIGHTS 16
188 #define WORLDMAT_CHANGED (0x00000001 << 0)
189 #define VIEWMAT_CHANGED (0x00000001 << 1)
190 #define PROJMAT_CHANGED (0x00000001 << 2)
192 struct IDirect3DDeviceImpl
194 ICOM_VFIELD_MULTI(IDirect3DDevice7);
195 ICOM_VFIELD_MULTI(IDirect3DDevice3);
196 ICOM_VFIELD_MULTI(IDirect3DDevice2);
197 ICOM_VFIELD_MULTI(IDirect3DDevice);
199 /* IDirect3DDevice fields */
201 IDirectDrawSurfaceImpl *surface;
203 IDirect3DViewportImpl *viewport_list;
204 IDirect3DViewportImpl *current_viewport;
205 D3DVIEWPORT7 active_viewport;
207 IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
209 /* Current transformation matrices */
210 D3DMATRIX *world_mat;
214 /* Current material used in D3D7 mode */
215 D3DMATERIAL7 current_material;
217 /* Light parameters */
218 DWORD active_lights, set_lights;
219 D3DLIGHT7 light_parameters[MAX_LIGHTS];
221 void (*set_context)(IDirect3DDeviceImpl*);
222 HRESULT (*clear)(IDirect3DDeviceImpl *This,
229 void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
230 void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
231 D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
233 STATEBLOCK state_block;
236 /*****************************************************************************
237 * IDirect3DVertexBuffer implementation structure
239 struct IDirect3DVertexBufferImpl
241 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
242 ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
245 D3DVERTEXBUFFERDESC desc;
247 DWORD vertex_buffer_size;
252 /* Various dump and helper functions */
253 extern const char *_get_renderstate(D3DRENDERSTATETYPE type);
254 extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat);
255 extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol);
256 extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight);
257 extern void dump_DPFLAGS(DWORD dwFlags);
258 extern void dump_D3DMATRIX(D3DMATRIX *mat);
259 extern void dump_D3DVECTOR(D3DVECTOR *lpVec);
260 extern void dump_flexible_vertex(DWORD d3dvtVertexType);
261 extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
262 extern void convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided);
263 extern void dump_D3DVOP(DWORD dwVertexOp);
264 extern void dump_D3DPV(DWORD dwFlags);
266 extern const float id_mat[16];
268 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */