1c2c66affSColin Finck /*
2c2c66affSColin Finck * Direct3DRM private interfaces (D3DRM.DLL)
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2010 Christian Costa
5c2c66affSColin Finck *
6c2c66affSColin Finck * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck * License as published by the Free Software Foundation; either
9c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck *
11c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14c2c66affSColin Finck * Lesser General Public License for more details.
15c2c66affSColin Finck *
16c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck */
20c2c66affSColin Finck
21c2c66affSColin Finck #ifndef __D3DRM_PRIVATE_INCLUDED__
22c2c66affSColin Finck #define __D3DRM_PRIVATE_INCLUDED__
23c2c66affSColin Finck
24c2c66affSColin Finck #define NONAMELESSUNION
25e792c304SAmine Khaldi #define NONAMELESSSTRUCT
26e792c304SAmine Khaldi #define COBJMACROS
27c2c66affSColin Finck #include <assert.h>
28c2c66affSColin Finck #include <math.h>
29e792c304SAmine Khaldi #include "dxfile.h"
30e792c304SAmine Khaldi #include "d3drmwin.h"
31e792c304SAmine Khaldi #include "rmxfguid.h"
32e792c304SAmine Khaldi #include "wine/debug.h"
33e792c304SAmine Khaldi #include "wine/heap.h"
34e792c304SAmine Khaldi #include "wine/list.h"
35c2c66affSColin Finck
36*3d017d71SAmine Khaldi struct d3drm_matrix
37*3d017d71SAmine Khaldi {
38*3d017d71SAmine Khaldi float _11, _12, _13, _14;
39*3d017d71SAmine Khaldi float _21, _22, _23, _24;
40*3d017d71SAmine Khaldi float _31, _32, _33, _34;
41*3d017d71SAmine Khaldi float _41, _42, _43, _44;
42*3d017d71SAmine Khaldi };
43*3d017d71SAmine Khaldi
d3drm_matrix(D3DRMMATRIX4D m)44*3d017d71SAmine Khaldi static inline struct d3drm_matrix *d3drm_matrix(D3DRMMATRIX4D m)
45*3d017d71SAmine Khaldi {
46*3d017d71SAmine Khaldi return (struct d3drm_matrix *)m;
47*3d017d71SAmine Khaldi }
48*3d017d71SAmine Khaldi
49c2c66affSColin Finck struct d3drm_object
50c2c66affSColin Finck {
51c2c66affSColin Finck LONG ref;
52c2c66affSColin Finck DWORD appdata;
53c2c66affSColin Finck struct list destroy_callbacks;
54c2c66affSColin Finck const char *classname;
55c2c66affSColin Finck char *name;
56c2c66affSColin Finck };
57c2c66affSColin Finck
58c2c66affSColin Finck struct d3drm_texture
59c2c66affSColin Finck {
60c2c66affSColin Finck struct d3drm_object obj;
61c2c66affSColin Finck IDirect3DRMTexture IDirect3DRMTexture_iface;
62c2c66affSColin Finck IDirect3DRMTexture2 IDirect3DRMTexture2_iface;
63c2c66affSColin Finck IDirect3DRMTexture3 IDirect3DRMTexture3_iface;
64c2c66affSColin Finck IDirect3DRM *d3drm;
65c2c66affSColin Finck D3DRMIMAGE *image;
66c2c66affSColin Finck IDirectDrawSurface *surface;
67c2c66affSColin Finck };
68c2c66affSColin Finck
69c2c66affSColin Finck struct d3drm_frame
70c2c66affSColin Finck {
71c2c66affSColin Finck struct d3drm_object obj;
72c2c66affSColin Finck IDirect3DRMFrame IDirect3DRMFrame_iface;
73c2c66affSColin Finck IDirect3DRMFrame2 IDirect3DRMFrame2_iface;
74c2c66affSColin Finck IDirect3DRMFrame3 IDirect3DRMFrame3_iface;
75c2c66affSColin Finck IDirect3DRM *d3drm;
76c2c66affSColin Finck LONG ref;
77c2c66affSColin Finck struct d3drm_frame *parent;
78c2c66affSColin Finck SIZE_T nb_children;
79c2c66affSColin Finck SIZE_T children_size;
80c2c66affSColin Finck IDirect3DRMFrame3 **children;
81c2c66affSColin Finck SIZE_T nb_visuals;
82c2c66affSColin Finck SIZE_T visuals_size;
83c2c66affSColin Finck IDirect3DRMVisual **visuals;
84c2c66affSColin Finck SIZE_T nb_lights;
85c2c66affSColin Finck SIZE_T lights_size;
86c2c66affSColin Finck IDirect3DRMLight **lights;
87*3d017d71SAmine Khaldi struct d3drm_matrix transform;
88c2c66affSColin Finck D3DCOLOR scenebackground;
89c2c66affSColin Finck DWORD traversal_options;
90c2c66affSColin Finck };
91c2c66affSColin Finck
92*3d017d71SAmine Khaldi struct d3drm_box
93*3d017d71SAmine Khaldi {
94*3d017d71SAmine Khaldi float left;
95*3d017d71SAmine Khaldi float top;
96*3d017d71SAmine Khaldi float right;
97*3d017d71SAmine Khaldi float bottom;
98*3d017d71SAmine Khaldi float front;
99*3d017d71SAmine Khaldi float back;
100*3d017d71SAmine Khaldi };
101*3d017d71SAmine Khaldi
102c2c66affSColin Finck struct d3drm_viewport
103c2c66affSColin Finck {
104c2c66affSColin Finck struct d3drm_object obj;
105c2c66affSColin Finck struct d3drm_device *device;
106c2c66affSColin Finck IDirect3DRMFrame *camera;
107c2c66affSColin Finck IDirect3DRMViewport IDirect3DRMViewport_iface;
108c2c66affSColin Finck IDirect3DRMViewport2 IDirect3DRMViewport2_iface;
109c2c66affSColin Finck IDirect3DViewport *d3d_viewport;
110c2c66affSColin Finck IDirect3DMaterial *material;
111c2c66affSColin Finck IDirect3DRM *d3drm;
112*3d017d71SAmine Khaldi struct d3drm_box clip;
113c2c66affSColin Finck D3DRMPROJECTIONTYPE projection;
114c2c66affSColin Finck };
115c2c66affSColin Finck
116c2c66affSColin Finck struct d3drm_device
117c2c66affSColin Finck {
118c2c66affSColin Finck struct d3drm_object obj;
119c2c66affSColin Finck IDirect3DRMDevice IDirect3DRMDevice_iface;
120c2c66affSColin Finck IDirect3DRMDevice2 IDirect3DRMDevice2_iface;
121c2c66affSColin Finck IDirect3DRMDevice3 IDirect3DRMDevice3_iface;
122c2c66affSColin Finck IDirect3DRMWinDevice IDirect3DRMWinDevice_iface;
123c2c66affSColin Finck IDirect3DRM *d3drm;
124c2c66affSColin Finck IDirectDraw *ddraw;
125c2c66affSColin Finck IDirectDrawSurface *primary_surface, *render_target;
126c2c66affSColin Finck IDirectDrawClipper *clipper;
127c2c66affSColin Finck IDirect3DDevice *device;
128c2c66affSColin Finck BOOL dither;
129c2c66affSColin Finck D3DRMRENDERQUALITY quality;
130c2c66affSColin Finck DWORD rendermode;
131c2c66affSColin Finck DWORD height;
132c2c66affSColin Finck DWORD width;
133c2c66affSColin Finck };
134c2c66affSColin Finck
135c2c66affSColin Finck struct d3drm_face
136c2c66affSColin Finck {
137c2c66affSColin Finck struct d3drm_object obj;
138c2c66affSColin Finck IDirect3DRMFace IDirect3DRMFace_iface;
139c2c66affSColin Finck IDirect3DRMFace2 IDirect3DRMFace2_iface;
140c2c66affSColin Finck LONG ref;
141c2c66affSColin Finck D3DCOLOR color;
142c2c66affSColin Finck };
143c2c66affSColin Finck
144c2c66affSColin Finck struct d3drm_mesh_builder
145c2c66affSColin Finck {
146c2c66affSColin Finck struct d3drm_object obj;
147c2c66affSColin Finck IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
148c2c66affSColin Finck IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
149c2c66affSColin Finck LONG ref;
150c2c66affSColin Finck IDirect3DRM *d3drm;
151c2c66affSColin Finck SIZE_T nb_vertices;
152c2c66affSColin Finck SIZE_T vertices_size;
153c2c66affSColin Finck D3DVECTOR *vertices;
154c2c66affSColin Finck SIZE_T nb_normals;
155c2c66affSColin Finck SIZE_T normals_size;
156c2c66affSColin Finck D3DVECTOR *normals;
157c2c66affSColin Finck DWORD nb_faces;
158c2c66affSColin Finck DWORD face_data_size;
159c2c66affSColin Finck void *pFaceData;
160c2c66affSColin Finck DWORD nb_coords2d;
161c2c66affSColin Finck struct coords_2d *pCoords2d;
162c2c66affSColin Finck D3DCOLOR color;
163c2c66affSColin Finck IDirect3DRMMaterial2 *material;
164c2c66affSColin Finck IDirect3DRMTexture3 *texture;
165c2c66affSColin Finck DWORD nb_materials;
166c2c66affSColin Finck struct mesh_material *materials;
167c2c66affSColin Finck DWORD *material_indices;
168c2c66affSColin Finck };
169c2c66affSColin Finck
170c2c66affSColin Finck struct mesh_group
171c2c66affSColin Finck {
172c2c66affSColin Finck unsigned nb_vertices;
173c2c66affSColin Finck D3DRMVERTEX* vertices;
174c2c66affSColin Finck unsigned nb_faces;
175c2c66affSColin Finck unsigned vertex_per_face;
176c2c66affSColin Finck DWORD face_data_size;
177c2c66affSColin Finck unsigned* face_data;
178c2c66affSColin Finck D3DCOLOR color;
179c2c66affSColin Finck IDirect3DRMMaterial2* material;
180c2c66affSColin Finck IDirect3DRMTexture3* texture;
181c2c66affSColin Finck };
182c2c66affSColin Finck
183c2c66affSColin Finck struct d3drm_mesh
184c2c66affSColin Finck {
185c2c66affSColin Finck struct d3drm_object obj;
186c2c66affSColin Finck IDirect3DRMMesh IDirect3DRMMesh_iface;
187c2c66affSColin Finck LONG ref;
188c2c66affSColin Finck IDirect3DRM *d3drm;
189c2c66affSColin Finck SIZE_T nb_groups;
190c2c66affSColin Finck SIZE_T groups_size;
191c2c66affSColin Finck struct mesh_group *groups;
192c2c66affSColin Finck };
193c2c66affSColin Finck
194c2c66affSColin Finck struct d3drm_light
195c2c66affSColin Finck {
196c2c66affSColin Finck struct d3drm_object obj;
197c2c66affSColin Finck IDirect3DRMLight IDirect3DRMLight_iface;
198c2c66affSColin Finck LONG ref;
199c2c66affSColin Finck IDirect3DRM *d3drm;
200c2c66affSColin Finck D3DRMLIGHTTYPE type;
201c2c66affSColin Finck D3DCOLOR color;
202c2c66affSColin Finck D3DVALUE range;
203c2c66affSColin Finck D3DVALUE cattenuation;
204c2c66affSColin Finck D3DVALUE lattenuation;
205c2c66affSColin Finck D3DVALUE qattenuation;
206c2c66affSColin Finck D3DVALUE umbra;
207c2c66affSColin Finck D3DVALUE penumbra;
208c2c66affSColin Finck };
209c2c66affSColin Finck
210c2c66affSColin Finck struct color_rgb
211c2c66affSColin Finck {
212c2c66affSColin Finck D3DVALUE r;
213c2c66affSColin Finck D3DVALUE g;
214c2c66affSColin Finck D3DVALUE b;
215c2c66affSColin Finck };
216c2c66affSColin Finck
217c2c66affSColin Finck struct d3drm_material
218c2c66affSColin Finck {
219c2c66affSColin Finck struct d3drm_object obj;
220c2c66affSColin Finck IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface;
221c2c66affSColin Finck LONG ref;
222c2c66affSColin Finck IDirect3DRM *d3drm;
223c2c66affSColin Finck struct color_rgb emissive;
224c2c66affSColin Finck struct color_rgb specular;
225c2c66affSColin Finck D3DVALUE power;
226c2c66affSColin Finck struct color_rgb ambient;
227c2c66affSColin Finck };
228c2c66affSColin Finck
229c2c66affSColin Finck struct d3drm_animation_key
230c2c66affSColin Finck {
231c2c66affSColin Finck D3DVALUE time;
232c2c66affSColin Finck union
233c2c66affSColin Finck {
234c2c66affSColin Finck D3DVECTOR position;
235c2c66affSColin Finck D3DVECTOR scale;
236c2c66affSColin Finck D3DRMQUATERNION rotate;
237c2c66affSColin Finck } u;
238c2c66affSColin Finck };
239c2c66affSColin Finck
240c2c66affSColin Finck struct d3drm_animation_keys
241c2c66affSColin Finck {
242c2c66affSColin Finck struct d3drm_animation_key *keys;
243c2c66affSColin Finck SIZE_T count;
244c2c66affSColin Finck SIZE_T size;
245c2c66affSColin Finck };
246c2c66affSColin Finck
247c2c66affSColin Finck struct d3drm_animation
248c2c66affSColin Finck {
249c2c66affSColin Finck struct d3drm_object obj;
250c2c66affSColin Finck IDirect3DRMAnimation2 IDirect3DRMAnimation2_iface;
251c2c66affSColin Finck IDirect3DRMAnimation IDirect3DRMAnimation_iface;
252c2c66affSColin Finck LONG ref;
253c2c66affSColin Finck IDirect3DRM *d3drm;
254c2c66affSColin Finck IDirect3DRMFrame3 *frame;
255c2c66affSColin Finck D3DRMANIMATIONOPTIONS options;
256c2c66affSColin Finck struct d3drm_animation_keys position;
257c2c66affSColin Finck struct d3drm_animation_keys scale;
258c2c66affSColin Finck struct d3drm_animation_keys rotate;
259c2c66affSColin Finck };
260c2c66affSColin Finck
261c2c66affSColin Finck struct d3drm_wrap
262c2c66affSColin Finck {
263c2c66affSColin Finck struct d3drm_object obj;
264c2c66affSColin Finck IDirect3DRMWrap IDirect3DRMWrap_iface;
265c2c66affSColin Finck LONG ref;
266c2c66affSColin Finck };
267c2c66affSColin Finck
268c2c66affSColin Finck HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
269c2c66affSColin Finck HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw,
270c2c66affSColin Finck IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN;
271c2c66affSColin Finck void d3drm_device_destroy(struct d3drm_device *device) DECLSPEC_HIDDEN;
272c2c66affSColin Finck HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw,
273c2c66affSColin Finck IDirectDrawSurface *surface, BOOL create_z_surface) DECLSPEC_HIDDEN;
274c2c66affSColin Finck
275c2c66affSColin Finck void d3drm_object_init(struct d3drm_object *object, const char *classname) DECLSPEC_HIDDEN;
276c2c66affSColin Finck HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
277c2c66affSColin Finck HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
278c2c66affSColin Finck HRESULT d3drm_object_get_class_name(struct d3drm_object *object, DWORD *size, char *name) DECLSPEC_HIDDEN;
279c2c66affSColin Finck HRESULT d3drm_object_get_name(struct d3drm_object *object, DWORD *size, char *name) DECLSPEC_HIDDEN;
280c2c66affSColin Finck HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name) DECLSPEC_HIDDEN;
281c2c66affSColin Finck void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN;
282c2c66affSColin Finck
283c2c66affSColin Finck struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface) DECLSPEC_HIDDEN;
284*3d017d71SAmine Khaldi struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface) DECLSPEC_HIDDEN;
285*3d017d71SAmine Khaldi
286c2c66affSColin Finck struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) DECLSPEC_HIDDEN;
287c2c66affSColin Finck
288c2c66affSColin Finck HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
289c2c66affSColin Finck HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
290c2c66affSColin Finck HRESULT d3drm_face_create(struct d3drm_face **face) DECLSPEC_HIDDEN;
291c2c66affSColin Finck HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
292c2c66affSColin Finck HRESULT d3drm_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
293c2c66affSColin Finck HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
294c2c66affSColin Finck HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
295c2c66affSColin Finck HRESULT d3drm_mesh_create(struct d3drm_mesh **mesh, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
296c2c66affSColin Finck HRESULT d3drm_animation_create(struct d3drm_animation **animation, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
297c2c66affSColin Finck HRESULT d3drm_wrap_create(struct d3drm_wrap **wrap, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
298c2c66affSColin Finck
299c2c66affSColin Finck HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data,
300c2c66affSColin Finck D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN;
301c2c66affSColin Finck
302c2c66affSColin Finck struct d3drm_file_header
303c2c66affSColin Finck {
304c2c66affSColin Finck WORD major;
305c2c66affSColin Finck WORD minor;
306c2c66affSColin Finck DWORD flags;
307c2c66affSColin Finck };
308c2c66affSColin Finck
309c2c66affSColin Finck extern char templates[] DECLSPEC_HIDDEN;
310c2c66affSColin Finck
d3drm_color_component(float c)311c2c66affSColin Finck static inline BYTE d3drm_color_component(float c)
312c2c66affSColin Finck {
313c2c66affSColin Finck if (c <= 0.0f)
314c2c66affSColin Finck return 0u;
315c2c66affSColin Finck if (c >= 1.0f)
316c2c66affSColin Finck return 0xffu;
317c2c66affSColin Finck return floor(c * 255.0f);
318c2c66affSColin Finck }
319c2c66affSColin Finck
d3drm_set_color(D3DCOLOR * color,float r,float g,float b,float a)320c2c66affSColin Finck static inline void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a)
321c2c66affSColin Finck {
322c2c66affSColin Finck *color = RGBA_MAKE(d3drm_color_component(r), d3drm_color_component(g),
323c2c66affSColin Finck d3drm_color_component(b), d3drm_color_component(a));
324c2c66affSColin Finck }
325c2c66affSColin Finck
326c2c66affSColin Finck BOOL d3drm_array_reserve(void **elements, SIZE_T *capacity, SIZE_T element_count, SIZE_T element_size) DECLSPEC_HIDDEN;
327c2c66affSColin Finck
328c2c66affSColin Finck #endif /* __D3DRM_PRIVATE_INCLUDED__ */
329