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