- implement the texturing the D3D3 way
[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 /*****************************************************************************
30  * Predeclare the interface implementation structures
31  */
32 typedef struct IDirect3DImpl IDirect3DImpl;
33 typedef struct IDirect3DLightImpl IDirect3DLightImpl;
34 typedef struct IDirect3DMaterialImpl IDirect3DMaterialImpl;
35 typedef struct IDirect3DTextureImpl IDirect3DTextureImpl;
36 typedef struct IDirect3DViewportImpl IDirect3DViewportImpl;
37 typedef struct IDirect3DExecuteBufferImpl IDirect3DExecuteBufferImpl;
38 typedef struct IDirect3DDeviceImpl IDirect3DDeviceImpl;
39 typedef struct IDirect3DVertexBufferImpl IDirect3DVertexBufferImpl;
40
41 #include "ddraw_private.h"
42
43 /*****************************************************************************
44  * IDirect3D implementation structure.
45  * This is common for interfaces 1, 2, 3 and 7.
46  */
47 struct IDirect3DImpl
48 {
49     ICOM_VFIELD_MULTI(IDirect3D7);
50     ICOM_VFIELD_MULTI(IDirect3D3);
51     ICOM_VFIELD_MULTI(IDirect3D2);
52     ICOM_VFIELD_MULTI(IDirect3D);
53     DWORD                   ref;
54     /* IDirect3D fields */
55     IDirectDrawImpl*    ddraw;
56 };
57
58 /*****************************************************************************
59  * IDirect3DLight implementation structure
60  */
61 struct IDirect3DLightImpl
62 {
63     ICOM_VFIELD_MULTI(IDirect3DLight);
64     DWORD ref;
65     /* IDirect3DLight fields */
66     IDirect3DImpl *d3d;
67
68     D3DLIGHT2 light;
69
70     /* Chained list used for adding / removing from viewports */
71     IDirect3DLightImpl *next;
72
73     /* Activation function */
74     void (*activate)(IDirect3DLightImpl*);
75     void (*desactivate)(IDirect3DLightImpl*);
76     void (*update)(IDirect3DLightImpl*);
77 };
78
79 /*****************************************************************************
80  * IDirect3DMaterial implementation structure
81  */
82 struct IDirect3DMaterialImpl
83 {
84     ICOM_VFIELD_MULTI(IDirect3DMaterial3);
85     ICOM_VFIELD_MULTI(IDirect3DMaterial2);
86     ICOM_VFIELD_MULTI(IDirect3DMaterial);
87     DWORD  ref;
88     /* IDirect3DMaterial2 fields */
89     IDirect3DImpl *d3d;
90     IDirect3DDeviceImpl *active_device;
91
92     D3DMATERIAL mat;
93
94     void (*activate)(IDirect3DMaterialImpl* this);
95 };
96
97 /*****************************************************************************
98  * IDirect3DTexture implementation structure
99  */
100 struct IDirect3DTextureImpl
101 {
102     ICOM_VFIELD_MULTI(IDirect3DTexture2);
103     ICOM_VFIELD_MULTI(IDirect3DTexture);
104     DWORD ref;
105     /* IDirect3DTexture fields */
106     IDirect3DImpl *d3d;
107     IDirect3DDeviceImpl *d3ddevice;
108     IDirectDrawSurfaceImpl *surface;
109     BOOL loaded;
110 };
111
112 /*****************************************************************************
113  * IDirect3DViewport implementation structure
114  */
115 struct IDirect3DViewportImpl
116 {
117     ICOM_VFIELD_MULTI(IDirect3DViewport3);
118     DWORD ref;
119     /* IDirect3DViewport fields */
120     IDirect3DImpl *d3d;
121     /* If this viewport is active for one device, put the device here */
122     IDirect3DDeviceImpl *active_device;
123
124     int use_vp2;
125     union {
126         D3DVIEWPORT vp1;
127         D3DVIEWPORT2 vp2;
128     } viewports;
129
130     /* Activation function */
131     void (*activate)(IDirect3DViewportImpl*);
132
133     /* Field used to chain viewports together */
134     IDirect3DViewportImpl *next;
135
136     /* Lights list */
137     IDirect3DLightImpl *lights;
138 };
139
140 /*****************************************************************************
141  * IDirect3DExecuteBuffer implementation structure
142  */
143 struct IDirect3DExecuteBufferImpl
144 {
145     ICOM_VFIELD_MULTI(IDirect3DExecuteBuffer);
146     DWORD ref;
147     /* IDirect3DExecuteBuffer fields */
148     IDirect3DImpl *d3d;
149     IDirect3DDeviceImpl* d3ddev;
150
151     D3DEXECUTEBUFFERDESC desc;
152     D3DEXECUTEDATA data;
153
154     /* This buffer will store the transformed vertices */
155     void* vertex_data;
156     D3DVERTEXTYPE vertex_type;
157
158     /* This flags is set to TRUE if we allocated ourselves the
159        data buffer */
160     BOOL need_free;
161
162     void (*execute)(IDirect3DExecuteBufferImpl* this,
163                     IDirect3DDeviceImpl* dev,
164                     IDirect3DViewportImpl* vp);
165 };
166
167 /*****************************************************************************
168  * IDirect3DDevice implementation structure
169  */
170
171 #define MAX_TEXTURES 8
172
173 struct IDirect3DDeviceImpl
174 {
175     ICOM_VFIELD_MULTI(IDirect3DDevice7);
176     ICOM_VFIELD_MULTI(IDirect3DDevice3);
177     ICOM_VFIELD_MULTI(IDirect3DDevice2);
178     ICOM_VFIELD_MULTI(IDirect3DDevice);
179     DWORD  ref;
180     /* IDirect3DDevice fields */
181     IDirect3DImpl *d3d;
182     IDirectDrawSurfaceImpl *surface;
183
184     IDirect3DViewportImpl *viewport_list;
185     IDirect3DViewportImpl *current_viewport;
186     IDirect3DTextureImpl *current_texture[MAX_TEXTURES];
187
188     void (*set_context)(IDirect3DDeviceImpl*);
189 };
190
191 /*****************************************************************************
192  * IDirect3DVertexBuffer implementation structure
193  */
194 struct IDirect3DVertexBufferImpl
195 {
196     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer7);
197     ICOM_VFIELD_MULTI(IDirect3DVertexBuffer);
198     DWORD ref;
199     IDirect3DImpl *d3d;
200     D3DVERTEXBUFFERDESC desc;
201     LPVOID *vertices;
202     DWORD vertex_buffer_size;
203 };
204
205 /* Various dump functions */
206 extern const char *_get_renderstate(D3DRENDERSTATETYPE type);
207
208 #define dump_mat(mat) \
209     TRACE("%f %f %f %f\n", (mat)->_11, (mat)->_12, (mat)->_13, (mat)->_14); \
210     TRACE("%f %f %f %f\n", (mat)->_21, (mat)->_22, (mat)->_23, (mat)->_24); \
211     TRACE("%f %f %f %f\n", (mat)->_31, (mat)->_32, (mat)->_33, (mat)->_34); \
212     TRACE("%f %f %f %f\n", (mat)->_41, (mat)->_42, (mat)->_43, (mat)->_44);
213
214 #endif /* __GRAPHICS_WINE_D3D_PRIVATE_H */