1 /* 2 * Direct3DRM private interfaces (D3DRM.DLL) 3 * 4 * Copyright 2010 Christian Costa 5 * 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. 10 * 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. 15 * 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 19 */ 20 21 #ifndef __D3DRM_PRIVATE_INCLUDED__ 22 #define __D3DRM_PRIVATE_INCLUDED__ 23 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/heap.h" 34 #include "wine/list.h" 35 36 struct d3drm_object 37 { 38 LONG ref; 39 DWORD appdata; 40 struct list destroy_callbacks; 41 const char *classname; 42 char *name; 43 }; 44 45 struct d3drm_texture 46 { 47 struct d3drm_object obj; 48 IDirect3DRMTexture IDirect3DRMTexture_iface; 49 IDirect3DRMTexture2 IDirect3DRMTexture2_iface; 50 IDirect3DRMTexture3 IDirect3DRMTexture3_iface; 51 IDirect3DRM *d3drm; 52 D3DRMIMAGE *image; 53 IDirectDrawSurface *surface; 54 }; 55 56 struct d3drm_frame 57 { 58 struct d3drm_object obj; 59 IDirect3DRMFrame IDirect3DRMFrame_iface; 60 IDirect3DRMFrame2 IDirect3DRMFrame2_iface; 61 IDirect3DRMFrame3 IDirect3DRMFrame3_iface; 62 IDirect3DRM *d3drm; 63 LONG ref; 64 struct d3drm_frame *parent; 65 SIZE_T nb_children; 66 SIZE_T children_size; 67 IDirect3DRMFrame3 **children; 68 SIZE_T nb_visuals; 69 SIZE_T visuals_size; 70 IDirect3DRMVisual **visuals; 71 SIZE_T nb_lights; 72 SIZE_T lights_size; 73 IDirect3DRMLight **lights; 74 D3DRMMATRIX4D transform; 75 D3DCOLOR scenebackground; 76 DWORD traversal_options; 77 }; 78 79 struct d3drm_viewport 80 { 81 struct d3drm_object obj; 82 struct d3drm_device *device; 83 IDirect3DRMFrame *camera; 84 IDirect3DRMViewport IDirect3DRMViewport_iface; 85 IDirect3DRMViewport2 IDirect3DRMViewport2_iface; 86 IDirect3DViewport *d3d_viewport; 87 IDirect3DMaterial *material; 88 IDirect3DRM *d3drm; 89 D3DVALUE back; 90 D3DVALUE front; 91 D3DVALUE field; 92 D3DRMPROJECTIONTYPE projection; 93 }; 94 95 struct d3drm_device 96 { 97 struct d3drm_object obj; 98 IDirect3DRMDevice IDirect3DRMDevice_iface; 99 IDirect3DRMDevice2 IDirect3DRMDevice2_iface; 100 IDirect3DRMDevice3 IDirect3DRMDevice3_iface; 101 IDirect3DRMWinDevice IDirect3DRMWinDevice_iface; 102 IDirect3DRM *d3drm; 103 IDirectDraw *ddraw; 104 IDirectDrawSurface *primary_surface, *render_target; 105 IDirectDrawClipper *clipper; 106 IDirect3DDevice *device; 107 BOOL dither; 108 D3DRMRENDERQUALITY quality; 109 DWORD rendermode; 110 DWORD height; 111 DWORD width; 112 }; 113 114 struct d3drm_face 115 { 116 struct d3drm_object obj; 117 IDirect3DRMFace IDirect3DRMFace_iface; 118 IDirect3DRMFace2 IDirect3DRMFace2_iface; 119 LONG ref; 120 D3DCOLOR color; 121 }; 122 123 struct d3drm_mesh_builder 124 { 125 struct d3drm_object obj; 126 IDirect3DRMMeshBuilder2 IDirect3DRMMeshBuilder2_iface; 127 IDirect3DRMMeshBuilder3 IDirect3DRMMeshBuilder3_iface; 128 LONG ref; 129 IDirect3DRM *d3drm; 130 SIZE_T nb_vertices; 131 SIZE_T vertices_size; 132 D3DVECTOR *vertices; 133 SIZE_T nb_normals; 134 SIZE_T normals_size; 135 D3DVECTOR *normals; 136 DWORD nb_faces; 137 DWORD face_data_size; 138 void *pFaceData; 139 DWORD nb_coords2d; 140 struct coords_2d *pCoords2d; 141 D3DCOLOR color; 142 IDirect3DRMMaterial2 *material; 143 IDirect3DRMTexture3 *texture; 144 DWORD nb_materials; 145 struct mesh_material *materials; 146 DWORD *material_indices; 147 }; 148 149 struct mesh_group 150 { 151 unsigned nb_vertices; 152 D3DRMVERTEX* vertices; 153 unsigned nb_faces; 154 unsigned vertex_per_face; 155 DWORD face_data_size; 156 unsigned* face_data; 157 D3DCOLOR color; 158 IDirect3DRMMaterial2* material; 159 IDirect3DRMTexture3* texture; 160 }; 161 162 struct d3drm_mesh 163 { 164 struct d3drm_object obj; 165 IDirect3DRMMesh IDirect3DRMMesh_iface; 166 LONG ref; 167 IDirect3DRM *d3drm; 168 SIZE_T nb_groups; 169 SIZE_T groups_size; 170 struct mesh_group *groups; 171 }; 172 173 struct d3drm_light 174 { 175 struct d3drm_object obj; 176 IDirect3DRMLight IDirect3DRMLight_iface; 177 LONG ref; 178 IDirect3DRM *d3drm; 179 D3DRMLIGHTTYPE type; 180 D3DCOLOR color; 181 D3DVALUE range; 182 D3DVALUE cattenuation; 183 D3DVALUE lattenuation; 184 D3DVALUE qattenuation; 185 D3DVALUE umbra; 186 D3DVALUE penumbra; 187 }; 188 189 struct color_rgb 190 { 191 D3DVALUE r; 192 D3DVALUE g; 193 D3DVALUE b; 194 }; 195 196 struct d3drm_material 197 { 198 struct d3drm_object obj; 199 IDirect3DRMMaterial2 IDirect3DRMMaterial2_iface; 200 LONG ref; 201 IDirect3DRM *d3drm; 202 struct color_rgb emissive; 203 struct color_rgb specular; 204 D3DVALUE power; 205 struct color_rgb ambient; 206 }; 207 208 struct d3drm_animation_key 209 { 210 D3DVALUE time; 211 union 212 { 213 D3DVECTOR position; 214 D3DVECTOR scale; 215 D3DRMQUATERNION rotate; 216 } u; 217 }; 218 219 struct d3drm_animation_keys 220 { 221 struct d3drm_animation_key *keys; 222 SIZE_T count; 223 SIZE_T size; 224 }; 225 226 struct d3drm_animation 227 { 228 struct d3drm_object obj; 229 IDirect3DRMAnimation2 IDirect3DRMAnimation2_iface; 230 IDirect3DRMAnimation IDirect3DRMAnimation_iface; 231 LONG ref; 232 IDirect3DRM *d3drm; 233 IDirect3DRMFrame3 *frame; 234 D3DRMANIMATIONOPTIONS options; 235 struct d3drm_animation_keys position; 236 struct d3drm_animation_keys scale; 237 struct d3drm_animation_keys rotate; 238 }; 239 240 struct d3drm_wrap 241 { 242 struct d3drm_object obj; 243 IDirect3DRMWrap IDirect3DRMWrap_iface; 244 LONG ref; 245 }; 246 247 HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 248 HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, 249 IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN; 250 void d3drm_device_destroy(struct d3drm_device *device) DECLSPEC_HIDDEN; 251 HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw, 252 IDirectDrawSurface *surface, BOOL create_z_surface) DECLSPEC_HIDDEN; 253 254 void d3drm_object_init(struct d3drm_object *object, const char *classname) DECLSPEC_HIDDEN; 255 HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN; 256 HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN; 257 HRESULT d3drm_object_get_class_name(struct d3drm_object *object, DWORD *size, char *name) DECLSPEC_HIDDEN; 258 HRESULT d3drm_object_get_name(struct d3drm_object *object, DWORD *size, char *name) DECLSPEC_HIDDEN; 259 HRESULT d3drm_object_set_name(struct d3drm_object *object, const char *name) DECLSPEC_HIDDEN; 260 void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN; 261 262 struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface) DECLSPEC_HIDDEN; 263 struct d3drm_device *unsafe_impl_from_IDirect3DRMDevice3(IDirect3DRMDevice3 *iface) DECLSPEC_HIDDEN; 264 265 HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 266 HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 267 HRESULT d3drm_face_create(struct d3drm_face **face) DECLSPEC_HIDDEN; 268 HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 269 HRESULT d3drm_mesh_builder_create(struct d3drm_mesh_builder **mesh_builder, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 270 HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 271 HRESULT d3drm_material_create(struct d3drm_material **material, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 272 HRESULT d3drm_mesh_create(struct d3drm_mesh **mesh, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 273 HRESULT d3drm_animation_create(struct d3drm_animation **animation, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 274 HRESULT d3drm_wrap_create(struct d3drm_wrap **wrap, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; 275 276 HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data, 277 D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN; 278 279 struct d3drm_file_header 280 { 281 WORD major; 282 WORD minor; 283 DWORD flags; 284 }; 285 286 extern char templates[] DECLSPEC_HIDDEN; 287 288 static inline BYTE d3drm_color_component(float c) 289 { 290 if (c <= 0.0f) 291 return 0u; 292 if (c >= 1.0f) 293 return 0xffu; 294 return floor(c * 255.0f); 295 } 296 297 static inline void d3drm_set_color(D3DCOLOR *color, float r, float g, float b, float a) 298 { 299 *color = RGBA_MAKE(d3drm_color_component(r), d3drm_color_component(g), 300 d3drm_color_component(b), d3drm_color_component(a)); 301 } 302 303 BOOL d3drm_array_reserve(void **elements, SIZE_T *capacity, SIZE_T element_count, SIZE_T element_size) DECLSPEC_HIDDEN; 304 305 #endif /* __D3DRM_PRIVATE_INCLUDED__ */ 306