ok() does not support '%S'. Store the Ansi version, convert to Unicode
[wine] / dlls / ddraw / d3d_private.h
1 /* Direct3D private include file
2  * Copyright (c) 1998 Lionel ULMER
3  *
4  * This file contains all the structure that are not exported
5  * through d3d.h and all common macros.
6  *
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.
11  *
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.
16  *
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
20  */
21
22 #ifndef __GRAPHICS_WINE_D3D_PRIVATE_H
23 #define __GRAPHICS_WINE_D3D_PRIVATE_H
24
25 /* THIS FILE MUST NOT CONTAIN X11 or MESA DEFINES */
26
27 #include "d3d.h"
28
29 #define MAX_TEXTURES 8
30 #define MAX_LIGHTS  16
31
32 #define HIGHEST_RENDER_STATE         152
33 #define HIGHEST_TEXTURE_STAGE_STATE   24
34
35 /*****************************************************************************
36  * Predeclare the interface implementation structures
37  */
38 typedef struct IDirect3DImpl IDirect3DImpl;
39 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
40 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
41 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
42 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
43 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
44 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
45
46 #include "ddraw_private.h"
47
48 typedef struct STATEBLOCKFLAGS {
49    BOOL render_state[HIGHEST_RENDER_STATE];
50    BOOL texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE];
51 } STATEBLOCKFLAGS;
52
53 typedef struct STATEBLOCK {
54    STATEBLOCKFLAGS set_flags; 
55    DWORD render_state[HIGHEST_RENDER_STATE];
56    DWORD texture_stage_state[MAX_TEXTURES][HIGHEST_TEXTURE_STAGE_STATE];
57 } STATEBLOCK;
58
59 /*****************************************************************************
60  * IDirect3D implementation structure.
61  * This is common for interfaces 1, 2, 3 and 7.
62  */
63 struct IDirect3DImpl
64 {
65     ICOM_VFIELD_MULTI(IDirect3D7);
66     ICOM_VFIELD_MULTI(IDirect3D3);
67     ICOM_VFIELD_MULTI(IDirect3D2);
68     ICOM_VFIELD_MULTI(IDirect3D);
69     DWORD                   ref;
70     /* IDirect3D fields */
71     IDirectDrawImpl*    ddraw;
72
73     /* Used as a callback function to create a texture */
74     HRESULT (*create_texture)(IDirect3DImpl *d3d, IDirectDrawSurfaceImpl *tex, BOOLEAN at_creation, IDirectDrawSurfaceImpl *main);
75
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);
79
80     /* This is needed for delayed texture creation and Z buffer blits */
81     IDirect3DDeviceImpl *current_device;
82 };
83
84 /*****************************************************************************
85  * IDirect3DLight implementation structure
86  */
87 struct IDirect3DLightImpl
88 {
89     ICOM_VFIELD_MULTI(IDirect3DLight);
90     DWORD ref;
91     /* IDirect3DLight fields */
92     IDirect3DImpl *d3d;
93
94     D3DLIGHT2 light;
95
96     /* Chained list used for adding / removing from viewports */
97     IDirect3DLightImpl *next;
98
99     /* Activation function */
100     void (*activate)(IDirect3DLightImpl*);
101     void (*desactivate)(IDirect3DLightImpl*);
102     void (*update)(IDirect3DLightImpl*);
103 };
104
105 /*****************************************************************************
106  * IDirect3DMaterial implementation structure
107  */
108 struct IDirect3DMaterialImpl
109 {
110     ICOM_VFIELD_MULTI(IDirect3DMaterial3);
111     ICOM_VFIELD_MULTI(IDirect3DMaterial2);
112     ICOM_VFIELD_MULTI(IDirect3DMaterial);
113     DWORD  ref;
114     /* IDirect3DMaterial2 fields */
115     IDirect3DImpl *d3d;
116     IDirect3DDeviceImpl *active_device;
117
118     D3DMATERIAL mat;
119
120     void (*activate)(IDirect3DMaterialImpl* this);
121 };
122
123 /*****************************************************************************
124  * IDirect3DViewport implementation structure
125  */
126 struct IDirect3DViewportImpl
127 {
128     ICOM_VFIELD_MULTI(IDirect3DViewport3);
129     DWORD ref;
130     /* IDirect3DViewport fields */
131     IDirect3DImpl *d3d;
132     /* If this viewport is active for one device, put the device here */
133     IDirect3DDeviceImpl *active_device;
134
135     int use_vp2;
136     union {
137         D3DVIEWPORT vp1;
138         D3DVIEWPORT2 vp2;
139     } viewports;
140
141     /* Activation function */
142     void (*activate)(IDirect3DViewportImpl*);
143
144     /* Field used to chain viewports together */
145     IDirect3DViewportImpl *next;
146
147     /* Lights list */
148     IDirect3DLightImpl *lights;
149
150     /* Background material */
151     IDirect3DMaterialImpl *background;
152 };
153
154 /*****************************************************************************
155  * IDirect3DExecuteBuffer implementation structure
156  */
157 struct IDirect3DExecuteBufferImpl
158 {
159     ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
160     DWORD ref;
161     /* IDirect3DExecuteBuffer fields */
162     IDirect3DImpl *d3d;
163     IDirect3DDeviceImpl* d3ddev;
164
165     D3DEXECUTEBUFFERDESC desc;
166     D3DEXECUTEDATA data;
167
168     /* This buffer will store the transformed vertices */
169     void* vertex_data;
170     D3DVERTEXTYPE vertex_type;
171
172     /* This flags is set to TRUE if we allocated ourselves the
173        data buffer */
174     BOOL need_free;
175
176     void (*execute)(IDirect3DExecuteBufferImpl* this,
177                     IDirect3DDeviceImpl* dev,
178                     IDirect3DViewportImpl* vp);
179 };
180
181 /* Internal structure to store the state of the clipping planes */
182 typedef struct d3d7clippingplane 
183 {
184     D3DVALUE plane[4];
185 } d3d7clippingplane;
186
187 /*****************************************************************************
188  * IDirect3DDevice implementation structure
189  */
190
191 #define WORLDMAT_CHANGED (0x00000001 << 0)
192 #define VIEWMAT_CHANGED  (0x00000001 << 1)
193 #define PROJMAT_CHANGED  (0x00000001 << 2)
194
195 struct IDirect3DDeviceImpl
196 {
197     ICOM_VFIELD_MULTI(IDirect3DDevice7);
198     ICOM_VFIELD_MULTI(IDirect3DDevice3);
199     ICOM_VFIELD_MULTI(IDirect3DDevice2);
200     ICOM_VFIELD_MULTI(IDirect3DDevice);
201     DWORD  ref;
202     /* IDirect3DDevice fields */
203     IDirect3DImpl *d3d;
204     IDirectDrawSurfaceImpl *surface;
205
206     IDirect3DViewportImpl *viewport_list;
207     IDirect3DViewportImpl *current_viewport;
208     D3DVIEWPORT7 active_viewport;
209
210     IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
211
212     /* Current transformation matrices */
213     D3DMATRIX *world_mat;
214     D3DMATRIX *view_mat;
215     D3DMATRIX *proj_mat;
216
217     /* Current material used in D3D7 mode */
218     D3DMATERIAL7 current_material;
219
220     /* Light parameters */
221     DWORD active_lights, set_lights;
222     D3DLIGHT7 light_parameters[MAX_LIGHTS];
223
224     /* clipping planes */
225     DWORD max_clipping_planes;
226     d3d7clippingplane *clipping_planes;
227     
228     void (*set_context)(IDirect3DDeviceImpl*);
229     HRESULT (*clear)(IDirect3DDeviceImpl *This,
230                      DWORD dwCount,
231                      LPD3DRECT lpRects,
232                      DWORD dwFlags,
233                      DWORD dwColor,
234                      D3DVALUE dvZ,
235                      DWORD dwStencil);
236     void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
237     void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
238                          D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
239
240     STATEBLOCK state_block;
241 };
242
243 /*****************************************************************************
244  * IDirect3DVertexBuffer implementation structure
245  */
246 struct IDirect3DVertexBufferImpl
247 {
248     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
249     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
250     DWORD ref;
251     IDirect3DImpl *d3d;
252     D3DVERTEXBUFFERDESC desc;
253     LPVOID *vertices;
254     DWORD vertex_buffer_size;
255
256     BOOLEAN processed;
257 };
258
259 /* Various dump and helper functions */
260 extern const char *_get_renderstate(D3DRENDERSTATETYPE type);
261 extern void dump_D3DMATERIAL7(LPD3DMATERIAL7 lpMat);
262 extern void dump_D3DCOLORVALUE(D3DCOLORVALUE *lpCol);
263 extern void dump_D3DLIGHT7(LPD3DLIGHT7 lpLight);
264 extern void dump_DPFLAGS(DWORD dwFlags);
265 extern void dump_D3DMATRIX(D3DMATRIX *mat);
266 extern void dump_D3DVECTOR(D3DVECTOR *lpVec);
267 extern void dump_flexible_vertex(DWORD d3dvtVertexType);
268 extern DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
269 extern void convert_FVF_to_strided_data(DWORD d3dvtVertexType, LPVOID lpvVertices, D3DDRAWPRIMITIVESTRIDEDDATA *strided);
270 extern void dump_D3DVOP(DWORD dwVertexOp);
271 extern void dump_D3DPV(DWORD dwFlags);
272
273 extern const float id_mat[16];
274
275 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */