d3drm: Make it possible to create material objects with CreateObject().
[wine.git] / dlls / d3drm / d3drm_private.h
blobd6b884f4d8e4466d80c01e410c917f291451d2a1
1 /*
2 * Direct3DRM private interfaces (D3DRM.DLL)
4 * Copyright 2010 Christian Costa
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __D3DRM_PRIVATE_INCLUDED__
22 #define __D3DRM_PRIVATE_INCLUDED__
24 #define NONAMELESSUNION
25 #define NONAMELESSSTRUCT
26 #define COBJMACROS
27 #include <assert.h>
28 #include <math.h>
29 #include "dxfile.h"
30 #include "d3drmwin.h"
31 #include "rmxfguid.h"
32 #include "wine/debug.h"
33 #include "wine/list.h"
35 #ifndef ARRAY_SIZE
36 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
37 #endif
39 struct d3drm_object
41 LONG ref;
42 DWORD appdata;
43 struct list destroy_callbacks;
44 const char *classname;
47 struct d3drm_texture
49 struct d3drm_object obj;
50 IDirect3DRMTexture IDirect3DRMTexture_iface;
51 IDirect3DRMTexture2 IDirect3DRMTexture2_iface;
52 IDirect3DRMTexture3 IDirect3DRMTexture3_iface;
53 IDirect3DRM *d3drm;
54 D3DRMIMAGE *image;
55 IDirectDrawSurface *surface;
58 struct d3drm_frame
60 struct d3drm_object obj;
61 IDirect3DRMFrame IDirect3DRMFrame_iface;
62 IDirect3DRMFrame2 IDirect3DRMFrame2_iface;
63 IDirect3DRMFrame3 IDirect3DRMFrame3_iface;
64 IDirect3DRM *d3drm;
65 LONG ref;
66 struct d3drm_frame *parent;
67 ULONG nb_children;
68 ULONG children_capacity;
69 IDirect3DRMFrame3 **children;
70 ULONG nb_visuals;
71 ULONG visuals_capacity;
72 IDirect3DRMVisual **visuals;
73 ULONG nb_lights;
74 ULONG lights_capacity;
75 IDirect3DRMLight **lights;
76 D3DRMMATRIX4D transform;
77 D3DCOLOR scenebackground;
80 struct d3drm_viewport
82 struct d3drm_object obj;
83 struct d3drm_device *device;
84 IDirect3DRMFrame *camera;
85 IDirect3DRMViewport IDirect3DRMViewport_iface;
86 IDirect3DRMViewport2 IDirect3DRMViewport2_iface;
87 IDirect3DViewport *d3d_viewport;
88 IDirect3DMaterial *material;
89 IDirect3DRM *d3drm;
90 D3DVALUE back;
91 D3DVALUE front;
92 D3DVALUE field;
93 D3DRMPROJECTIONTYPE projection;
96 struct d3drm_device
98 struct d3drm_object obj;
99 IDirect3DRMDevice IDirect3DRMDevice_iface;
100 IDirect3DRMDevice2 IDirect3DRMDevice2_iface;
101 IDirect3DRMDevice3 IDirect3DRMDevice3_iface;
102 IDirect3DRMWinDevice IDirect3DRMWinDevice_iface;
103 IDirect3DRM *d3drm;
104 IDirectDraw *ddraw;
105 IDirectDrawSurface *primary_surface, *render_target;
106 IDirectDrawClipper *clipper;
107 IDirect3DDevice *device;
108 BOOL dither;
109 D3DRMRENDERQUALITY quality;
110 DWORD rendermode;
111 DWORD height;
112 DWORD width;
115 struct d3drm_face
117 struct d3drm_object obj;
118 IDirect3DRMFace IDirect3DRMFace_iface;
119 IDirect3DRMFace2 IDirect3DRMFace2_iface;
120 LONG ref;
123 struct d3drm_mesh_builder
125 struct d3drm_object obj;
126 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface;
127 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface;
128 LONG ref;
129 IDirect3DRM *d3drm;
130 char* name;
131 SIZE_T nb_vertices;
132 SIZE_T vertices_size;
133 D3DVECTOR *vertices;
134 SIZE_T nb_normals;
135 SIZE_T normals_size;
136 D3DVECTOR *normals;
137 DWORD nb_faces;
138 DWORD face_data_size;
139 void *pFaceData;
140 DWORD nb_coords2d;
141 struct coords_2d *pCoords2d;
142 D3DCOLOR color;
143 IDirect3DRMMaterial2 *material;
144 IDirect3DRMTexture3 *texture;
145 DWORD nb_materials;
146 struct mesh_material *materials;
147 DWORD *material_indices;
150 struct d3drm_light
152 struct d3drm_object obj;
153 IDirect3DRMLight IDirect3DRMLight_iface;
154 LONG ref;
155 IDirect3DRM *d3drm;
156 D3DRMLIGHTTYPE type;
157 D3DCOLOR color;
158 D3DVALUE range;
159 D3DVALUE cattenuation;
160 D3DVALUE lattenuation;
161 D3DVALUE qattenuation;
162 D3DVALUE umbra;
163 D3DVALUE penumbra;
166 struct color_rgb
168 D3DVALUE r;
169 D3DVALUE g;
170 D3DVALUE b;
173 struct d3drm_material
175 struct d3drm_object obj;
176 IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface;
177 LONG ref;
178 IDirect3DRM *d3drm;
179 struct color_rgb emissive;
180 struct color_rgb specular;
181 D3DVALUE power;
182 struct color_rgb ambient;
185 HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
186 HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw,
187 IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN;
188 void d3drm_device_destroy(struct d3drm_device *device) DECLSPEC_HIDDEN;
189 HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw,
190 IDirectDrawSurface *surface, BOOL create_z_surface) DECLSPEC_HIDDEN;
192 void d3drm_object_init(struct d3drm_object *object, const char *classname) DECLSPEC_HIDDEN;
193 HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
194 HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
195 HRESULT d3drm_object_get_class_name(struct d3drm_object *object, DWORD *size, char *name) DECLSPEC_HIDDEN;
196 void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN;
198 struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface) DECLSPEC_HIDDEN;
199 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) DECLSPEC_HIDDEN;
201 HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
202 HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
203 HRESULT d3drm_face_create(struct d3drm_face **face) DECLSPEC_HIDDEN;
204 HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
205 HRESULT d3drm_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
206 HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
207 HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
208 HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj) DECLSPEC_HIDDEN;
210 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data,
211 D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN;
213 struct d3drm_file_header
215 WORD major;
216 WORD minor;
217 DWORD flags;
220 extern char templates[] DECLSPEC_HIDDEN;
222 static inline BYTE d3drm_color_component(float c)
224 if (c <= 0.0f)
225 return 0u;
226 if (c >= 1.0f)
227 return 0xffu;
228 return floor(c * 255.0f);
231 static inline void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a)
233 *color = RGBA_MAKE(d3drm_color_component(r), d3drm_color_component(g),
234 d3drm_color_component(b), d3drm_color_component(a));
237 #endif /* __D3DRM_PRIVATE_INCLUDED__ */