1 /* 2 * Copyright (C) 1997-2005, R3vis Corporation. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 17 * USA, or visit http://www.gnu.org/copyleft/lgpl.html. 18 * 19 * Original Contributor: 20 * Wes Bethel, R3vis Corporation, Marin County, California 21 * Additional Contributor(s): 22 * 23 * The OpenRM project is located at http://openrm.sourceforge.net/. 24 */ 25 26 /* 27 * $Id: rmtypes.h,v 1.18 2005/06/26 18:47:12 wes Exp $ 28 * Version: $Name: OpenRM-1-6-0-2-RC2 $ 29 * $Revision: 1.18 $ 30 * $Log: rmtypes.h,v $ 31 * Revision 1.18 2005/06/26 18:47:12 wes 32 * Added glAttrib state mask stack to RMpipe to aid in state tracking. 33 * 34 * Revision 1.17 2005/05/28 16:26:34 wes 35 * Added pickEnable attribute to RMnodes, and function prototypes for 36 * rmNodeSetPickEnable and rmNodeGetPickEnable 37 * 38 * Revision 1.16 2005/04/27 03:34:10 wes 39 * Fix up declarations for multitexturing functions. 40 * 41 * Revision 1.15 2005/02/27 19:32:55 wes 42 * Added support for application supplied texture object IDs and display lists. 43 * 44 * Revision 1.14 2005/02/24 16:16:37 wes 45 * Added support for fbClears to be set at the RMpipe level. Apps can 46 * still set them at the RMnode level if desired for fine-grained control. 47 * 48 * Revision 1.13 2005/02/19 16:47:24 wes 49 * Distro sync and consolidation. 50 * 51 * Revision 1.12 2005/01/23 17:17:34 wes 52 * Copyright update to 2005. 53 * Updates to support use of extensions: multitexturing on all platforms, 54 * 3d texturing (for volume rendering support) on Win32 55 * 56 * Revision 1.11 2004/03/10 01:48:27 wes 57 * Added prototype for rmIndexedQuadStrip draw routine. 58 * 59 * Revision 1.10 2004/02/23 03:04:29 wes 60 * New primitives: RM_QUAD_STRIP, RM_INDEXED_TRIANGLES, RM_INDEXED_QUADS, 61 * RM_INDEXED_TRIANGLE_STRIP. 62 * 63 * Revision 1.9 2004/01/17 04:06:42 wes 64 * Updated Copyright line for 2004. 65 * 66 * Revision 1.8 2003/12/01 02:13:37 wes 67 * Additions to support constate-rate rendering on Unix and Win32. 68 * 69 * Revision 1.7 2003/11/22 00:53:52 wes 70 * Changes to support RMtextures being shared when assigned as scene parameters 71 * to properly implement instancing. 72 * 73 * Revision 1.6 2003/11/05 15:36:54 wes 74 * Added RMtime struct. 75 * 76 * Revision 1.5 2003/04/05 14:15:49 wes 77 * Added comments explaining role of some RMpipe fields. 78 * 79 * Revision 1.4 2003/02/14 00:15:32 wes 80 * Added CR-specific structure to the RMpipe, used to hold CR-specific things. 81 * 82 * Revision 1.3 2003/02/02 17:50:55 wes 83 * Added bounding boxes to RMprimitives, as a supplement to node-level bboxes. 84 * The RMprimitive level bboxes are needed for the retained-mode CR work. 85 * 86 * Revision 1.2 2003/02/02 02:07:14 wes 87 * Updated copyright to 2003. 88 * 89 * Revision 1.1.1.1 2003/01/28 02:15:23 wes 90 * Manual rebuild of rm150 repository. 91 * 92 * Revision 1.18 2003/01/27 05:04:27 wes 93 * Changes to RMpipe API and initialization sequence to unify GLX, WGL and CR 94 * platforms w/o too much disruption to existing apps. 95 * 96 * Revision 1.17 2003/01/11 18:43:28 wes 97 * Added global control over display list use at the RMpipe level with 98 * new routines rmPipeSetDisplayListEnable() and rmPipeGetDisplayListEnable(). 99 * 100 * Revision 1.16 2002/12/31 00:56:21 wes 101 * Cleaned up arch-specific portions of RMpipe to support Chromium. 102 * 103 * Revision 1.15 2002/12/04 14:50:30 wes 104 * Cleanup SGI compiles. 105 * 106 * Revision 1.14 2002/09/02 23:49:27 wes 107 * Modifications for Win32 to support dynamic object pools. 108 * 109 * Revision 1.13 2002/08/29 22:21:13 wes 110 * Massive upgrade to accommodate dynamic object reallocation within 111 * the component manager, and within the context cache. Use the 112 * debug #define DEBUG_LEVEL DEBUG_REALLOC_TRACE to get a printf 113 * whenever a realloc occurs. With this upgrade, there are no 114 * OpenRM limits on the size of the scene graph. There will be external 115 * limits, such as the amount of RAM and the amount of space available 116 * to your OpenGL implementation. 117 * 118 * Revision 1.12 2002/08/17 15:18:43 wes 119 * Modified node struct to accommodate the render order callback. 120 * 121 * Revision 1.11 2002/06/02 15:19:23 wes 122 * Added RMstateCache code to help eliminate the number of state changes 123 * made during the render traversal. The RMstateCache tracks 124 * the actual OpenGL rendering state w/o the need for querying OpenGL 125 * directly, and is queried by draw code that then decides if any 126 * real state changes are required given the configuration of data 127 * within an RMprimitive. 128 * 129 * Revision 1.10 2002/04/30 19:42:33 wes 130 * Updated copyright dates. 131 * 132 * Revision 1.9 2001/10/15 00:17:38 wes 133 * Added two new fog-related fields to the RMstate struct. 134 * 135 * Revision 1.8 2001/07/15 17:21:20 wes 136 * Removed dead code. 137 * 138 * Revision 1.7 2001/03/31 17:13:59 wes 139 * v1.4.0-alpha-2 checkin 140 * 141 * Revision 1.6 2000/12/03 23:20:22 wes 142 * Thread-safety mods. 143 * 144 * Revision 1.5 2000/09/02 19:26:21 wes 145 * Updated comments inside code. 146 * 147 * Revision 1.4 2000/05/17 14:31:19 wes 148 * Added rmPolys() (thanks to Matt and Todd at VRCO). 149 * 150 * Revision 1.3 2000/04/20 17:41:46 wes 151 * Minor CVS tag changes. 152 * 153 * Revision 1.2 2000/04/20 16:30:24 wes 154 * Added copyright info. 155 * 156 * Revision 1.1.1.1 2000/02/28 21:29:40 wes 157 * OpenRM 1.2 Checkin 158 * 159 * Revision 1.1.1.1 2000/02/28 17:18:48 wes 160 * Initial entry - pre-RM120 release, source base for OpenRM 1.2. 161 * 162 */ 163 164 #ifndef _rmtypes_h 165 #define _rmtypes_h 166 167 #ifdef RM_WIN 168 #include <sys/types.h> 169 /* why can't MS use standard type definitions?? */ 170 typedef _off_t off_t; 171 #endif 172 173 #include <rm/rmthread.h> 174 #include <rm/rmcmpmgr.h> 175 176 #ifndef GLAPIENTRY 177 178 #ifdef RM_WIN 179 #define GLAPIENTRY __stdcall 180 #endif 181 #ifdef RM_X 182 #define GLAPIENTRY 183 #endif 184 185 #endif 186 187 /* constants and limits */ 188 #define MAX_VIS_CMAP_ENTRIES 256 189 #define RMV_DEFAULT_MAP_SIZE 256 190 #define OBJECT_NAME_LENGTH 64 191 192 #ifdef __cplusplus 193 extern "C" { 194 #endif 195 196 /* color types [4] */ 197 typedef struct RMcolor1D 198 { 199 float lum; 200 } RMcolor1D; 201 202 typedef struct RMcolor2D 203 { 204 float lum, alpha; 205 } RMcolor2D; 206 207 typedef struct RMcolor3D 208 { 209 float r, g, b; 210 } RMcolor3D; 211 212 typedef struct RMcolor4D 213 { 214 float r, g, b, a; 215 } RMcolor4D; 216 217 /* vertex types [3] */ 218 typedef struct RMvertex2D 219 { 220 float x, y; 221 } RMvertex2D; 222 223 typedef struct RMvertex3D 224 { 225 float x, y, z; 226 } RMvertex3D; 227 228 typedef struct RMvertex4D 229 { 230 float x, y, z, w; 231 } RMvertex4D; 232 233 typedef struct RMmatrix 234 { 235 float m[4][4]; 236 } RMmatrix; 237 238 typedef struct RMarray 239 { 240 int nItems; /* # of items currently in array */ 241 int currentArraySize; /* current size of array. should be >= nItems */ 242 int elementSize; /* size in bytes of each array element */ 243 int chunkSize; /* realloc size is chunkSize * elementSize bytes */ 244 void *data; 245 } RMarray; 246 247 /* 32 bit cache key */ 248 typedef unsigned int RMcacheKey; 249 #define RM_CACHEKEY_UNINITIALIZED_VALUE (unsigned int)(-1) 250 251 #if 0 252 /* 64 bit cache key */ 253 typedef unsigned long RMcacheKey; 254 #endif 255 256 typedef struct RMinternalMarker2D 257 { 258 int npts; 259 int gl_begin_flag; 260 RMvertex2D *vlist; 261 } RMinternalMarker2D; 262 263 typedef struct RMvisMap 264 { 265 int nentries; 266 float r[MAX_VIS_CMAP_ENTRIES]; 267 float g[MAX_VIS_CMAP_ENTRIES]; 268 float b[MAX_VIS_CMAP_ENTRIES]; 269 float a[MAX_VIS_CMAP_ENTRIES]; 270 float transfer_min, transfer_max; 271 } RMvisMap; 272 273 typedef struct RMbitmap 274 { 275 int w, h; 276 int bytes_per_scanline; 277 int pbsize; 278 unsigned char *pixeldata; 279 } RMbitmap; 280 281 typedef struct RMimage 282 { 283 /* configuration */ 284 int ndims; /* 2 or 3, set implicitly by user */ 285 int w, h, d; /* set by user */ 286 RMenum image_format; /* set by user: RM_IMAGE_RGB, etc. */ 287 RMenum image_type; /* set by user: RM_IMAGE_BYTE, etc. */ 288 float xzoom, yzoom; /* for 2d images only, user supplied, default 1.0, 1.0 */ 289 290 /* pixel data */ 291 RMenum copy_flag; /* set by user */ 292 void *pixeldata; /* set by user */ 293 void (*appfreefunc)(void *); /* set by user */ 294 295 /* colormap */ 296 RMvisMap *vismap; /* set by user, default NULL */ 297 298 /* scale & bias */ 299 float scale, bias; 300 301 /* internals, private */ 302 int bytes_per_component; /* computed by RM */ 303 int bytes_per_scanline; /* computed by RM */ 304 int elements; /* computed by RM */ 305 #if 0 306 /* display list stuff removed 10/5/2000 */ 307 int d1; 308 RMenum dirty_flag; 309 #endif 310 unsigned int pbsize; 311 312 /* internal, component manager */ 313 int compListIndx; 314 315 /* internal, context cache key */ 316 RMcacheKey cacheKey; 317 } RMimage; 318 319 typedef struct RMcamera2D 320 { 321 float xmin, ymin, xmax, ymax; /* defines extents of camera (like a viewport, but in R2 world coords) */ 322 float aspect_ratio; 323 } RMcamera2D; 324 325 typedef struct _RMStereoCameraControls 326 { 327 void (*preframe_leftchannel_func)(); 328 void (*preframe_rightchannel_func)(); 329 } _RMStereoCameraControls; 330 331 typedef struct RMcamera3D 332 { 333 /* camera points */ 334 RMvertex3D eye; 335 RMvertex3D at; 336 RMvertex3D up; 337 338 float hither, yon; /* near & far */ 339 float fov; /* field of view angle in degrees in the Y direction */ 340 float aspect; /* aspect ratio (width / height) --> field of view angle in X direction */ 341 RMenum projection; /* may be RM_PROJECTION_PERSPECTIVE or RM_PROJECTION_ORTHOGRAPHIC */ 342 RMenum isStereo; /* flag for stereo (RM_TRUE or RM_FALSE) */ 343 float degrees_eye_separation; /* for stereo cameras only */ 344 float focalDistance; /* for stereo cameras only */ 345 } RMcamera3D; 346 347 typedef struct RMtextProps 348 { 349 int fontEnum; /* one of RM_FONT_SERIF,RM_FONT_SANS, RM_FONT_MONO, RM_FONT_SYMBOL */ 350 RMenum italicEnum; /* RM_TRUE or RM_FALSE */ 351 RMenum boldEnum; /* RM_TRUE or RM_FALSE */ 352 int sizeEnum; /* enum of RM_FONT_XXS, RM_FONT_XS, RM_FONT_S, RM_FONT_M, RM_FONT_L, RM_FONT_XL, RM_FONT_XXL */ 353 RMenum hJustify, vJustify; 354 int listbase; /* OpenGL dislay list base (computed by RM at runtime) */ 355 int listoffset; /* OpenGL display list stuff (computed by RM at runtime) */ 356 void *fontinfo; 357 358 int compListIndx; 359 } RMtextProps; 360 361 typedef struct _bounding_box 362 { 363 RMvertex3D min; 364 RMvertex3D max; 365 } _bounding_box; 366 367 typedef struct RMclipPlane 368 { 369 RMenum enabled; /* RM_TRUE, RM_FALSE */ 370 RMvertex3D point; 371 RMvertex3D normal; /* (point, normal) parametrization */ 372 float a, b, c, d; /* plane equation */ 373 } RMclipPlane; 374 375 typedef struct RMlight 376 { 377 /* individual light ala OpenGL Light (see glLight) */ 378 RMenum ltype; /* RM_LIGHT_POINT, RM_LIGHT_DIRECTIONAL, RM_SPOT */ 379 RMcolor4D ambientLightColor; 380 RMcolor4D diffuseLightColor; 381 RMcolor4D specularLightColor; 382 RMvertex3D lightXYZ; /* position for point and spot lights, direction for directional light sources */ 383 float spotCutoff; /* [0.0, 90.0] degrees */ 384 float spotExponent; /* default = 0.0, higher numbers produce more focused spots */ 385 RMvertex3D spotDirection; 386 float constantAttenuation; 387 float linearAttenuation; 388 float quadraticAttenuation; 389 RMenum enabled; /* RM_TRUE or RM_FALSE */ 390 } RMlight; 391 392 typedef struct RMlightModel 393 { 394 /* light model parms ala OpenGL Light Model (see glLightModel) */ 395 RMcolor4D globalAmbient; 396 GLenum twoSideEnable; 397 GLenum localViewerEnable; 398 } RMlightModel; 399 400 typedef struct RMtexture 401 { 402 RMimage *images[RM_MAX_MIPMAPS]; 403 GLuint *appTextureID; /* these two could go in a union 404 since both are not simultaneously usable. */ 405 406 int dims; /* 1, 2 or 3d texture */ 407 int nmipmaps; /* number of mipmaps associated w/this texture */ 408 409 /* flags for OpenGL */ 410 GLenum mag_filter_mode; /* for GL_TEXTURE_MAG_FILTER */ 411 GLenum min_filter_mode; /* for GL_TEXTURE_MIN_FILTER */ 412 GLenum wrap_mode; /* applied to each of u, v, w */ 413 414 /* OpenGL has extra options for texel storage modes */ 415 GLenum *oglTexelFormat; /* GL_RGBA, GL_RGB, etc. default is GL_RGBA */ 416 417 /* environment modes */ 418 GLenum envMode; /* see man glTexEnv */ 419 RMcolor4D *blendColor; /* see man glTexEnv */ 420 421 int borderWidth; /* texture border */ 422 423 /* residency status currently not used. */ 424 RMenum residency_status; /* internal: RM_TRUE or RM_FALSE */ 425 426 /* for the component manager */ 427 int compListIndx; 428 429 /* internal, context cache keys for texture IDs and texture data */ 430 RMcacheKey cacheKeyID; 431 RMcacheKey cacheKeyData; 432 433 /* reference counting - indicates whether or not a shared texture is 434 assigned as a scene parameter to an RMnode */ 435 int refCount; 436 } RMtexture; 437 438 typedef struct RMfog 439 { 440 GLenum fogMode; /* GL_LINEAR, GL_EXP or GL_EXP2, def GL_LINEAR */ 441 GLfloat fogDensity; /* default = 1.0 */ 442 GLfloat fogStart; /* default is 0.0 */ 443 GLfloat fogEnd; /* default is 1 */ 444 RMcolor4D fogColor; /* default is 0,0,0,0 */ 445 } RMfog; 446 447 typedef struct RMstate 448 { 449 RMmatrix model; /* model transformations */ 450 RMmatrix view; /* viewing transformations */ 451 RMmatrix modelView; /* combined model & view (OGL style) */ 452 RMmatrix projection; /* projection matrix */ 453 RMmatrix composite; /* model*view*projection */ 454 RMmatrix pick; /* pick matrix */ 455 RMmatrix textureMatrix; /* texture matrix */ 456 RMmatrix projection_inverse; /* inverse of the concatenated view & projection matrices (?) */ 457 RMmatrix vpm; /* viewport matrix - from NDC to window */ 458 float vp[4]; /* (x, y) VP location + (w, h) VP width & height */ 459 float aspect_ratio; 460 float focal_length; 461 int w, h; /* window width & height */ 462 RMenum rendermode; 463 RMenum renderpass; 464 RMenum renderPassDims; /* to distinguish between 3D/2D traversals */ 465 RMenum which_channel; /* used */ 466 RMtexture *texture; /* current texture */ 467 int texture_mode; /* if current texture, GL_TEXTURE_2D, etc. */ 468 int attrib_stack_depth; /* current attribute stack depth */ 469 470 /* material properties */ 471 RMcolor4D ambient; 472 RMcolor4D diffuse; 473 RMcolor4D specular; 474 RMcolor4D emissive; 475 RMcolor4D unlit_color; 476 float specular_exponent; 477 float opacity; 478 479 /* line & point style */ 480 float pointsize; 481 RMenum linewidth; 482 RMenum linestyle; 483 484 /* render mode parms */ 485 RMenum shademodel; 486 487 /* polygon face properties */ 488 RMenum poly_mode_face; 489 RMenum poly_mode_drawstyle; 490 RMenum cull_mode; /* cull faces? [RM_CULL_NONE, RM_CULL_FRONT, RM_CULL_BACK, RM_CULL_FRONT_AND_BACK] */ 491 RMenum front_face; /* vertex winding? [RM_CCW, RM_CW] */ 492 493 /* clip planes */ 494 RMclipPlane *cp0; 495 RMclipPlane *cp1; 496 RMclipPlane *cp2; 497 RMclipPlane *cp3; 498 RMclipPlane *cp4; 499 RMclipPlane *cp5; 500 501 /* fog */ 502 RMenum fogActive; /* RM_TRUE if fog is active */ 503 RMfog fog; /* rather than creating copies */ 504 505 /* lighting */ 506 RMlightModel *lmodel; 507 RMlight *lightSources[RM_MAX_LIGHTS]; 508 509 /* text */ 510 RMtextProps *textProps; 511 512 int frameNumber; 513 514 /* internal use only */ 515 RMenum colorMaterialActive; 516 RMenum lightingActive; 517 } RMstate; 518 519 typedef struct 520 { 521 RMenum colorMaterialActive; /* in use */ 522 RMenum lightingActive; /* not yet used */ 523 RMenum texturingActive; /* not yet used */ 524 } RMstateCache; 525 526 typedef struct 527 { 528 RMcolor4D *ambient_color; 529 RMcolor4D *diffuse_color; 530 RMcolor4D *specular_color; 531 RMcolor4D *unlit_color; 532 float *specular_exponent; 533 float *opacity; 534 } _surface_properties; 535 536 typedef struct _rendermode_properties 537 { 538 RMenum *shademodel; /* shade? [RM_SHADER_SMOOTH, RM_SHADER_FLAT, RM_SHADER_NOLIGHT] */ 539 RMenum *poly_mode_face; 540 RMenum *poly_mode_drawstyle; 541 RMenum *cull_mode; /* cull faces? [RM_CULL_NONE, RM_CULL_FRONT, RM_CULL_BACK, RM_CULL_FRONT_AND_BACK] */ 542 RMenum *front_face; /* vertex winding? [RM_CCW, RM_CW] */ 543 float *pointsize; 544 RMenum *linewidth; 545 RMenum *linestyle; 546 RMenum *normalizeNormals; 547 } _rendermode_properties; 548 549 typedef struct internals_RMsceneParms 550 { 551 float *viewport; /* array of length 4: (x, y, w, h) in NDC [0..1], scales to window size */ 552 /* RMcolor4D *background_color; moved */ 553 /* RMimage *background_image_tile; moved */ 554 RMcamera3D *camera3d; 555 RMcamera2D *camera2d; 556 557 /* RMtexture *texture; modified during multitexturing upgrade 11/11/04 */ 558 RMtexture *textures[RM_MAX_MULTITEXTURES+1]; 559 RMenum haveAnyTextures; 560 561 /* float *depth_value; moved */ 562 /* RMimage *depth_image; moved */ 563 RMclipPlane *cp0; 564 RMclipPlane *cp1; 565 RMclipPlane *cp2; 566 RMclipPlane *cp3; 567 RMclipPlane *cp4; 568 RMclipPlane *cp5; 569 RMlightModel *lmodel; 570 RMlight *lightSources[RM_MAX_LIGHTS]; 571 RMtextProps *textProps; 572 RMfog *fog; 573 } internals_RMsceneParms; 574 575 typedef struct 576 { 577 RMcolor4D *bgColor; 578 RMimage *bgImageTile; 579 580 float *depthValue; 581 RMimage *depthImage; 582 } internals_RMfbClear; 583 584 typedef struct internals_RMtransformationStruct 585 { 586 /* 587 * transformations are applied in this order (left multiplication!): 588 * 589 * Pre * -C * S * R * S2 * C * T * Post 590 */ 591 RMmatrix pre; /* applied before any other transforms */ 592 RMmatrix s; /* pre-rotation scale */ 593 RMmatrix r; /* rotation */ 594 RMmatrix s2; /* post-rotation scale */ 595 RMvertex3D translate; /* translation vector */ 596 RMmatrix post; /* applied after other transforms */ 597 RMenum transform_mode; /* RM_TRANSFORM_GEOMETRY, RM_TRANSFORM_TEXTURE, RM_TRANSFORM_CAMERA, RM_TRANSFORM_IGNORE */ 598 } internals_RMtransformationStruct; 599 600 typedef struct _object_info 601 { 602 char name[OBJECT_NAME_LENGTH]; 603 604 /* node scheduling for rendering in a multipass/multichannel rendering environment */ 605 RMenum posted; /* controls whether or not is rendered */ 606 RMenum rpass_vdims; /* 2D or 3D coords? */ 607 RMenum rpass_opacity; /* RM_RENDERPASS_OPAQUE, RM_RENDERPASS_TRANSPARENT */ 608 RMenum channel; /* RM_LEFT_CHANNEL, RM_RIGHT_CHANNEL, RM_ALL_CHANNELS */ 609 RMenum pickEnable; /* when RM_TRUE, the node will be traversed 610 during pick operations. Default is RM_TRUE */ 611 } _object_info; 612 613 typedef struct RMnode 614 { 615 /* scene graph topology */ 616 struct RMnode *parent; 617 int nchildren; 618 struct RMnode **children; 619 620 /* here's the geometry */ 621 int nprims; 622 void **prims; 623 624 /* properties */ 625 _surface_properties *sprops; 626 _rendermode_properties *rprops; 627 internals_RMsceneParms *scene_parms; 628 629 /* fb clear control */ 630 internals_RMfbClear *fbClear; 631 632 /* bounding box info */ 633 _bounding_box bbox; 634 RMvertex3D center; 635 636 /* transformation info */ 637 internals_RMtransformationStruct *transforms; 638 639 /* misc scheduling info about the object */ 640 _object_info object_info; 641 642 /* callbacks */ 643 int (*viewPretraverseCallback) (const struct RMnode *, const RMstate *); 644 int (*viewPosttraverseCallback) (const struct RMnode *, const RMstate *); 645 646 int (*renderPretraverseCallback) (const struct RMnode *, const RMstate *); 647 int (*renderPosttraverseCallback) (const struct RMnode *, const RMstate *); 648 int (*viewSwitchCallback) (const struct RMnode *, const RMstate *); 649 /* 650 * 7/22/02. added view (stage) render order callback. note that the 651 * switch callback and renderOrder callbacks are (or should be) 652 * mutually-exclusive. such mutual-exclusivity is not reflected in 653 * the data structure or in the API at this time. 654 */ 655 int (*viewRenderOrderCallback) (const struct RMnode *, const RMstate *, int *orderIndices, int nChildren); 656 657 /* client data stuff - not multistage safe! (1/2001) */ 658 void *clientData; 659 void (*clientDataFreeFunc) (struct RMnode *, void *); 660 661 int refcount; 662 663 /* attribute mask */ 664 GLuint attribMask; 665 666 /* optional mutex */ 667 RMmutex *nodeMutex; 668 669 /* internal, component manager */ 670 int compListIndx; 671 } RMnode; 672 673 typedef struct RMfontRegistry /* PRIVATE */ 674 { 675 int initialized; 676 int refcount; 677 int listbase; 678 int listoffset; 679 int listCount; 680 void *fontinfo; 681 } RMfontRegistry; 682 683 /* 684 * context cache structure - used internally by RM to hold OpenGL 685 * display list IDs, texture IDs, etc. 686 * 687 * 8/28/02 - added num*CacheKeys fields to this struct in conjunction 688 * with dynamic object pools. 689 */ 690 typedef struct RMcontextCache 691 { 692 /* for RMprimitives */ 693 GLuint *primDisplayListIDs; 694 RMcacheKey *primCacheKeys; 695 int numPrimDisplayListIDs; 696 int numPrimCacheKeys; 697 698 /* for RMimages */ 699 GLuint *imgDisplayListIDs; 700 RMcacheKey *imgCacheKeys; 701 int numImgDisplayListIDs; 702 int numImgCacheKeys; 703 704 /* for RMtextures */ 705 GLuint *textureIDs; 706 RMcacheKey *textureIDCacheKeys; /* textureID management */ 707 RMcacheKey *textureDataCacheKeys; /* texture image data status */ 708 int numTextureIDs; 709 int numTextureIDCacheKeys; 710 int numTextureDataCacheKeys; 711 712 /* need to add this stuff VVVV */ 713 714 /* RM-built display lists for quadrics objects */ 715 GLuint *sphereIDs; 716 GLuint *coneIDs, *flipConeIDs; 717 GLuint *cylinderIDs, *flipCylinderIDs; 718 719 /* pre-rendered bitmap font glyph display list IDs */ 720 RMfontRegistry *pipeFontRegistry; 721 722 } RMcontextCache; 723 724 #ifdef RM_CR 725 typedef struct 726 { 727 crCreateContextProc glCreateContextCR; 728 crMakeCurrentProc glMakeCurrentCR; 729 crSwapBuffersProc glSwapBuffersCR; 730 731 glChromiumParametervCRProc glChromiumParametervCR; 732 glChromiumParameteriCRProc glChromiumParameteriCR; 733 glGetChromiumParametervCRProc glGetChromiumParametervCR; 734 glBarrierCreateCRProc glBarrierCreateCR; 735 glBarrierExecCRProc glBarrierExecCR; 736 } RMpipeCRvariables; 737 #endif 738 739 typedef struct 740 { 741 long sec; 742 long usec; 743 } RMtime; 744 745 /* 746 * new in RM 1.6.0: obtain & use special capabilities of the OpenGL 747 * implementation. 748 */ 749 typedef struct 750 { 751 /* ---------- multitexturing stuff ----------- */ 752 /* does this OpenGL support multitexturing? */ 753 RMenum haveMultiTexturing; 754 int numTextureUnits; 755 /* dynamically obtain multitexturing func pointers */ 756 void (GLAPIENTRY * activeTextureARB)(GLenum target); 757 void (GLAPIENTRY * multiTexCoord1fvARB)(GLenum target, float *s); 758 void (GLAPIENTRY * multiTexCoord2fvARB)(GLenum target, float *s); 759 void (GLAPIENTRY * multiTexCoord3fvARB)(GLenum target, float *s); 760 761 /* ---------- 3d textures stuff ------------- */ 762 /* does this OpenGL support 3D textures? */ 763 RMenum have3DTextures; 764 765 void (GLAPIENTRY * rm_glTexImage3D) (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); 766 void (GLAPIENTRY * rm_glTexSubImage3D) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); 767 768 } RMpipeOGLCapabilities; 769 770 typedef struct RMpipe 771 { 772 /* stuff common to all environments/OpenGL implementations */ 773 RMenum offscreen; /* RM_TRUE for offscreen formats, RM_FALSE otherwise */ 774 RMenum processingMode; 775 776 RMenum channel_format; 777 int xwindow_width, xwindow_height; 778 int xflags; 779 RMenum opaque3DEnable, transparent3DEnable, opaque2DEnable; 780 RMenum initMatrixStack; /* RM_TRUE or RM_FALSE */ 781 int frameNumber; 782 783 /* global control over use of display lists */ 784 RMenum displayListEnableBool; 785 786 /* Context Cache stuff */ 787 RMcontextCache *contextCache; /* the context cache */ 788 789 void *displayLists; /* multistage rendering buffers. Note: these are 790 NOT OpenGL display lists!! This buffer contains 791 structures generated by the view-stage traversal 792 that are consumed by the draw-stage traversal */ 793 794 void *mtControl; /* multistage process/thread control structure */ 795 796 #ifdef RM_X 797 /* stuff specific to X */ 798 Display *xdisplay; 799 XVisualInfo *xvisual; 800 Window xdrawable; 801 GLXContext glxcontext; 802 Colormap xcolormap; 803 #endif 804 805 #ifdef RM_WIN 806 /* stuff specific to Win32 */ 807 HDC hdc; 808 HWND hwnd; 809 HGLRC hRC; 810 #endif 811 812 #ifdef RM_CR 813 /* stuff specific to Chromium */ 814 int contextCR; 815 RMpipeCRvariables *crStuff; /* see rmcr.c */ 816 #endif 817 818 int myRank, globalNPE; 819 RMenum targetPlatform; 820 821 /* pipe callbacks, all platforms */ 822 /* 1. render function */ 823 void (*channel_render_func)(RMnode *t, struct RMpipe *p); 824 825 /* 826 * 2. optional app callback invoked after rendering, but before 827 * the "swapbuffers" call. can be used to perform synchronization 828 * between multiple rendering engines. 829 */ 830 void (*postRenderBarrierFunc)(struct RMpipe *p); 831 832 /* 3. color and depth buffer acquisition, swap buffer function */ 833 void (*postrenderfunc)(const RMimage *, RMenum whichBufferEnum); 834 void (*postrender_depthbufferfunc)(const RMimage *, RMenum whichBufferEnum); 835 /* 4. swap buffers func */ 836 RMenum (*swapBuffersFunc)(const struct RMpipe *); 837 838 /* 5. shutdown function */ 839 void (*shutdownFunc)(struct RMpipe *); 840 841 /* 842 * 12/26/02 - specialized barrier functions added during Chromium work. 843 * for now, these funcs are added outside of the RM_CR def to minimize 844 * the amount of arch-specific stuff. 845 */ 846 void (*postFBClearBarrierFunc)(const struct RMpipe *p); 847 848 /* 849 * context creation function - a per-platform thing 850 */ 851 RMenum (*createContextFunc)(struct RMpipe *p); 852 853 /* 854 * stuff related to constant time rendering 855 */ 856 #define MAX_FRAME_SAMPLES 6 857 int targetFrameRate; /* frames per sec, set by user */ 858 RMtime timePerFrame; /* fps converted to sec/usec */ 859 double timePerFrameMS; /* ms per frame */ 860 RMtime lastTimeStart; /* when was last frame started? */ 861 RMtime lastRenderTime; /* elapsed time for last rendering */ 862 863 /* the timeSyncFunc is used as a post-render, pre-swapbuffers 864 rendezvous point */ 865 void (*timeSyncFunc)(struct RMpipe *p); 866 867 /* 868 * new in 1.6.0 - special capabilities of the OpenGL implementation. 869 */ 870 RMpipeOGLCapabilities *caps; 871 872 /* new in 1.6.0 - RMpipe-level framebuffer clear controls. We use a 873 SG node to hold the RMpipe-level fbclear parameters as a roundabout 874 way of providing internal structure consistency for the routines that 875 generate PS output to avoid having yet another table of structs 876 for the fbclear objects. The extra level of indirection is something 877 of a PITA, but is less so than doing yet another managed table. */ 878 RMnode *fbClearNode; 879 880 /* 881 * Each pipe has stack used to hold the attrib masks associated with 882 * each attrib push/pop. In some cases, we need to twiddle our local 883 * state tracker cache on pops to reflect changes to the actual 884 * OpenGL state that occur on push/pops. The local stack allows us to 885 * do so w/o having to query OpenGL, which would add some small cost. 886 * 887 * The MAX_MASK_STACK_DEPTH value of 64 is >> the usual OpenGL 888 * attrib stack depth, which is usually around 8 or 16. 889 */ 890 891 #define MAX_MASK_STACK_DEPTH 64 892 GLuint localMaskStack[MAX_MASK_STACK_DEPTH]; 893 int localMaskStackTop; 894 } RMpipe; 895 896 897 typedef struct RMprimitiveDataBlob 898 { 899 void *ptr; /* pointer to the stuff */ 900 RMenum copyflag; 901 int nthings; /* how many things there are */ 902 int blobtype; /* what kind of blob? */ 903 int stride; /* size of individual thing */ 904 int veclen; /* vector length of data supplied */ 905 void (*appfreefunc)(void *);/* the app-supplied free function for when the copy-flag is set to RM_DONT_COPY_DATA */ 906 } RMprimitiveDataBlob; 907 908 #define OGLPRIMPARMLIST() (struct RMprimitive *p, RMnode *r, RMstate *s, RMpipe *renderPipe, RMstateCache *rsc) 909 910 typedef struct RMprimitive 911 { 912 RMenum type; 913 RMprimitiveDataBlob *blobs; /* verts, colors, norms, texture coords, etc. */ 914 /* Feb 2005 - add support for multitextures */ 915 RMprimitiveDataBlob *multiTextureCoordBlobs; /* only multitexture coords */ 916 int multiTextureCoordBlobsMask; 917 int numMultiTextureCoordBlobs; 918 919 /* methods, data, flags */ 920 void (*renderfunc) OGLPRIMPARMLIST(); /* RMprimitive stores a pointer to the primitive draw method */ 921 void *clientData; 922 void (*clientDataFreeFunc) (struct RMprimitive *p, void *cd); 923 void *p1; /* stuff that doesn't really fit into blobs */ 924 925 /* misc stuff - usage depends upon app */ 926 unsigned int flags1; 927 unsigned int model_flag; 928 int display_list_enable; 929 930 /* old stuff for compatibility */ 931 int utility; 932 933 /* internal, component manager */ 934 int compListIndx; 935 936 /* internal, context cache key */ 937 RMcacheKey cacheKey; 938 939 /* used by some primitives to track state of textures, etc. */ 940 RMcacheKey utilCacheKey; 941 942 /* bounding box stuff */ 943 RMvertex3D *bmin, *bmax; 944 RMenum (*primitiveComputeBoundingBoxFunc)(struct RMprimitive *); 945 946 } RMprimitive; 947 948 949 950 /* RM-supplied primitive rendering functions */ 951 void rmAppDisplayList OGLPRIMPARMLIST(); 952 void rmBitmap OGLPRIMPARMLIST(); 953 void rmBox2d OGLPRIMPARMLIST(); 954 void rmBox3d OGLPRIMPARMLIST(); 955 void rmBox3dWire OGLPRIMPARMLIST(); 956 void rmCircle2d OGLPRIMPARMLIST(); 957 void rmCones OGLPRIMPARMLIST(); 958 void rmCylinders OGLPRIMPARMLIST(); 959 void rmEllipse2d OGLPRIMPARMLIST(); 960 void rmIndexedBitmap OGLPRIMPARMLIST(); 961 void rmIndexedQuads OGLPRIMPARMLIST(); 962 void rmIndexedQuadStrip OGLPRIMPARMLIST(); 963 void rmIndexedText OGLPRIMPARMLIST(); 964 void rmIndexedTriangleFan OGLPRIMPARMLIST(); 965 void rmIndexedTriangles OGLPRIMPARMLIST(); 966 void rmIndexedTriangleStrip OGLPRIMPARMLIST(); 967 void rmLineStrip OGLPRIMPARMLIST(); 968 void rmLinesDisjoint OGLPRIMPARMLIST(); 969 void rmMarkers2D OGLPRIMPARMLIST(); 970 void rmOctmesh OGLPRIMPARMLIST(); 971 void rmPoints OGLPRIMPARMLIST(); 972 void rmPolys OGLPRIMPARMLIST(); 973 void rmQuadmesh OGLPRIMPARMLIST(); 974 void rmQuads OGLPRIMPARMLIST(); 975 void rmQuadStrip OGLPRIMPARMLIST(); 976 void rmSpheres OGLPRIMPARMLIST(); 977 void rmSprite OGLPRIMPARMLIST(); 978 void rmText OGLPRIMPARMLIST(); 979 void rmTrianglesDisjoint OGLPRIMPARMLIST(); 980 void rmTriangleFan OGLPRIMPARMLIST(); 981 void rmTrianglesConnected OGLPRIMPARMLIST(); 982 983 984 /* structure returned when picking */ 985 typedef struct RMpick 986 { 987 RMnode *node; 988 float zval; /* NDC z-value */ 989 unsigned int index; /* object index */ 990 unsigned int prim_index; /* primitive index */ 991 } RMpick; 992 993 #ifdef RM_X 994 #include "rmx.h" 995 #endif 996 997 #ifdef __cplusplus 998 } 999 #endif 1000 1001 #endif /* _rmtypes_h */ 1002 /* EOF */ 1003