HOOPS/3dGS I.M. Interface

     << Back      Full Index      Forward >>


hoops.h

00001 /*
00002  * Copyright (c) 1998 by Tech Soft 3D, LLC.
00003  * The information contained herein is confidential and proprietary to
00004  * Tech Soft 3D, LLC., and considered a trade secret as defined under
00005  * civil and criminal statutes.  Tech Soft 3D shall pursue its civil
00006  * and criminal remedies in the event of unauthorized use or misappropriation
00007  * of its trade secrets.  Use of this information by anyone other than
00008  * authorized employees of Tech Soft 3D, LLC. is granted only under a
00009  * written non-disclosure agreement, expressly prescribing the scope and
00010  * manner of such use.
00011  *
00012  * $Id: hoops_8h-source.html,v 1.29 2008-03-10 07:09:28 stage Exp $
00013  */
00014 
00015 #ifndef HOOPS_DEFINED
00016 
00017 /*
00018  * For each system, the following are defined:
00019  * 1. system define - used in system specific HOOPS files
00020  * 2. endianism
00021  * 3. RGB ordering - byte arrangement of colors (optional)
00022  * 4. <optional platform specific items>
00023  * 5. platform string - used in the HOOPS version message banner
00024  *
00025  * The systems appear in the same order as they appear in the tested.hw file.
00026  */
00027 
00028 #ifdef _AIX
00029 #   ifndef AIX_SYSTEM
00030 #       define  AIX_SYSTEM
00031 #   endif
00032 #   ifndef UNIX_SYSTEM
00033 #       define  UNIX_SYSTEM
00034 #   endif
00035 #   define      HOOPS_BIGENDIAN         1
00036 #   define      HK_PLATFORM             "AIX 4.3.2"
00037 #   define      HK_PLATFORM_ID          0x004
00038 #   define      HK_DEFAULT_PICTURE      "x11/:0.0"
00039 #   define      USE_PTHREADS_MUTEX
00040 #   define      ATAN2(_yy_,_xx_)        HI_ATan2(_yy_,_xx_)
00041 #   ifdef __64BIT__
00042 #       define  LONG_SIZE               64
00043 #       define  ALIGNMENT               3
00044 #   endif
00045 #endif
00046 #ifdef __hpux
00047 #   ifndef HPUX_SYSTEM
00048 #       define  HPUX_SYSTEM
00049 #   endif
00050 #   ifndef UNIX_SYSTEM
00051 #       define  UNIX_SYSTEM
00052 #   endif
00053 #   define      HOOPS_BIGENDIAN         1
00054 #   define      PREFERRED_RGB32         a, r, g, b
00055 #   define      RGB32_ORDER_ARGB
00056 #   define      HK_PLATFORM             "HP-UX 11.0"
00057 #   define      HK_PLATFORM_ID          0x008
00058 #   define      HK_DEFAULT_PICTURE      "x11/:0.0"
00059 #   define      USE_PTHREADS_MUTEX
00060 #   ifdef __LP64__
00061 #               define  LONG_SIZE                               64
00062 #               define  ALIGNMENT                               3
00063 #   endif
00064 #endif
00065 #ifdef __sgi
00066 #   ifndef IRIX_SYSTEM
00067 #       define  IRIX_SYSTEM
00068 #   endif
00069 #   ifndef UNIX_SYSTEM
00070 #       define  UNIX_SYSTEM
00071 #   endif
00072 #   define      HOOPS_BIGENDIAN         1
00073 #   if (_MIPS_SZLONG == 64)
00074 #       define  LONG_SIZE               64
00075 #       define  ALIGNMENT               3
00076 #   endif
00077 #   define      HK_PLATFORM             "IRIX 6.5"
00078 #   define      HK_PLATFORM_ID          0x010
00079 #   define      HK_DEFAULT_PICTURE      "opengl/:0.0"
00080 #   define      USE_PTHREADS_MUTEX
00081 #endif
00082 #ifdef __osf__
00083 #   ifndef OSF1_SYSTEM
00084 #       define  OSF1_SYSTEM
00085 #   endif
00086 #   ifndef UNIX_SYSTEM
00087 #       define  UNIX_SYSTEM
00088 #   endif
00089 #   define      HOOPS_BIGENDIAN         0
00090 #   define      PREFERRED_RGB32         b, g, r, a
00091 #   define      RGB32_ORDER_BGRA
00092 #   define      LONG_SIZE               64
00093 #   define      ALIGNMENT               3
00094 #   define      HK_PLATFORM             "DEC OSF/1 Alpha 4.0d"
00095 #   define      HK_PLATFORM_ID          0x002
00096 #   define      HK_DEFAULT_PICTURE      "x11/:0.0"
00097 #   define      USE_PTHREADS_MUTEX
00098 #endif
00099 #ifdef vms
00100 #   define      VMS_SYSTEM
00101 #   define      HOOPS_BIGENDIAN         0
00102 #   define      MULTIPLE_DOT_FILENAMES  0
00103 #   define      PREFERRED_RGB32         b, g, r, a
00104 #   define      RGB32_ORDER_BGRA
00105 #   ifdef VAX
00106 #       define  VMS_VAX_SYSTEM
00107 #       if CC$gfloat
00108 #           define      HK_PLATFORM     "OpenVMS/VAX /G_FLOAT 6.0"
00109 #       else
00110 #           define      HK_PLATFORM     "OpenVMS/VAX 6.0"
00111 #       endif
00112 #       ifndef DEBUG
00113 #           /* 'const' causes non-shareable addresses in code space,          */
00114 #           /* so don't do it for real builds (ok for debugging/syntax check) */
00115 #           define      const
00116 #       endif
00117 #       define  signed  /* doesn't like use of explicit signed */
00118 #   else
00119 #       define  VMS_AXP_SYSTEM  /* Alpha */
00120 #       if __IEEE_FLOAT
00121 #           define      HK_PLATFORM     "OpenVMS/AXP /IEEE_FLOAT 6.1"
00122 #       else
00123 #           define      HK_PLATFORM     "OpenVMS/AXP 6.1"
00124 #       endif
00125         void *__MEMSET(void *__s, int __c, unsigned int __n);
00126 #       define  SET_MEMORY(dest, size, value)   __MEMSET (dest, value, size)
00127 #   endif
00128 #   define      HK_PLATFORM_ID          0x001
00129 #   define      HK_DEFAULT_PICTURE      "x11/decw$display"
00130 #endif
00131 #ifdef __sun
00132 #   ifndef SOLARIS_SYSTEM
00133 #       define  SOLARIS_SYSTEM
00134 #   endif
00135 #   ifndef UNIX_SYSTEM
00136 #       define  UNIX_SYSTEM
00137 #   endif
00138 #   ifdef __sparc
00139 #       define      HOOPS_BIGENDIAN         1
00140 #       define      HK_PLATFORM             "Solaris-Sparc"
00141 #       define      HK_PLATFORM_ID          0x040
00142 #       define      HK_DEFAULT_PICTURE      "x11/:0.0"
00143 #       ifdef __sparcv9
00144 #           define  LONG_SIZE           64      
00145 #           define  ALIGNMENT           3
00146 #       endif
00147 #       define      USE_PTHREADS_MUTEX
00148 #   endif
00149 #   ifdef __i386
00150 #       define      HOOPS_BIGENDIAN         0
00151 #       define      HK_PLATFORM             "Solaris-I386"
00152 #       define      HK_PLATFORM_ID          0x040
00153 #       define      HK_DEFAULT_PICTURE      "x11/:0.0"
00154 #       define      USE_PTHREADS_MUTEX
00155 #       define      PREFERRED_RGB32         r, g, b, a
00156 #       define      RGB32_ORDER_RGBA
00157 #   endif
00158 #   ifdef __amd64
00159 #       define      HOOPS_BIGENDIAN         0
00160 #       define      HK_PLATFORM             "Solaris-AMD64"
00161 #       define      HK_PLATFORM_ID          0x040
00162 #       define      HK_DEFAULT_PICTURE      "x11/:0.0"
00163 #       define      LONG_SIZE               64      
00164 #       define      ALIGNMENT               3
00165 #       define      USE_PTHREADS_MUTEX
00166 #       define      PREFERRED_RGB32         r, g, b, a
00167 #       define      RGB32_ORDER_RGBA
00168 #   endif
00169 #endif
00170 #ifdef _MSC_VER
00171 
00172 #   pragma warning(disable: 4127)   // conditional expression is constant
00173 #   pragma warning(disable: 4244)   // conversion to int of smaller size
00174 #   pragma warning(disable: 4996)   // standard string functions considered unsafe
00175 
00176 #   ifndef WIN32_SYSTEM
00177 #       define  WIN32_SYSTEM
00178 #   endif
00179 #   ifndef WINDOWS_SYSTEM
00180 #       define  WINDOWS_SYSTEM
00181 #   endif
00182 
00183 #   define      HOOPS_BIGENDIAN         0
00184 #   define      PREFERRED_RGB32         b, g, r, a
00185 #   define      RGB32_ORDER_BGRA
00186 #   define      HK_PLATFORM_ID  0x200
00187 #   define      PATH_DELIMITER          '\\'
00188 #   define      PATH_DELIMITER_TWO      ':'
00189 
00190 #   ifdef HOOPS_WINDOWS_HDI_DRIVER
00191 #       define HOOPS_API __declspec(dllimport)
00192 #   else
00193 #       define HOOPS_API __declspec(dllexport)
00194 #   endif
00195 
00196 #   ifndef HC_CDECL
00197 #       define  HC_CDECL                        __cdecl
00198 #   endif
00199 #   ifndef HF_STDCL
00200 #       define  HF_STDCL                        __stdcall
00201 #   endif
00202 
00203 #   if defined(_M_AMD64) || defined(WIN64) || defined(_M_X64) || defined(_WIN64)
00204 #       define      POINTER_SIZED_INT __int64
00205 #       define      ALIGNMENT           3
00206 #       ifndef WIN64_SYSTEM
00207 #           define      WIN64_SYSTEM
00208 #       endif
00209 #       ifdef _M_IA64
00210 #       define      HK_PLATFORM "Microsoft Win64 IA64"
00211 #       endif
00212 #       ifdef _M_X64
00213 #       define      HK_PLATFORM "Microsoft Win64 X64"
00214 #       endif
00215 #   endif
00216 
00217 #   ifdef _M_IX86
00218 #       define      HK_PLATFORM     "Microsoft Win32 Intel x86"
00219 #       define      USE_M_IX86_ASM
00220 #   endif
00221 
00222 #   ifdef _WIN32_WCE
00223 #       define      HK_PLATFORM     "Microsoft Win32 CE"
00224 #       define      HK_DEFAULT_PICTURE      "msw/window0"
00225 #   endif
00226 
00227 #   ifndef HK_PLATFORM
00228 #       define      HK_PLATFORM     "Microsoft Win32 Unknown"
00229 #   endif
00230 
00231 #   ifndef _WIN32_WCE
00232 #   include     <math.h>
00233 #   define      _INCLUDED_SYSTEM_MATH_H_
00234 #   define      SINCOS(_val_,_sin_,_cos_) do {                  \
00235                     float _angle_ = DEGREES_TO_RADIANS (_val_); \
00236                     _sin_ = (float) sin (_angle_);              \
00237                     _cos_ = (float) cos (_angle_);              \
00238                 } while (0)
00239 #   define      COS(_val_)      (float) cos (DEGREES_TO_RADIANS (_val_))
00240 #   define      DISABLE_SINCOS_LOOKUP_TABLES
00241 #   endif
00242 
00243 #   ifndef  HK_DEFAULT_PICTURE
00244 #       define      HK_DEFAULT_PICTURE      "opengl/window0"
00245 #   endif
00246 #endif
00247 #ifdef __linux__
00248 #   ifndef LINUX_SYSTEM
00249 #       define  LINUX_SYSTEM
00250 #   endif
00251 #   ifndef UNIX_SYSTEM
00252 #       define  UNIX_SYSTEM
00253 #   endif
00254 #   define      HOOPS_BIGENDIAN         0
00255 #   define      PREFERRED_RGB32         r, g, b, a
00256 #   define      RGB32_ORDER_RGBA
00257 #   define      HK_PLATFORM             "Linux"
00258 #   define      HK_PLATFORM_ID          0x400
00259 #   define      HK_DEFAULT_PICTURE      "x11/:0.0"
00260 #   define      USE_PTHREADS_MUTEX
00261 #   ifdef _LP64
00262 #       define  LONG_SIZE               64
00263 #       define  ALIGNMENT               3
00264 #   endif
00265 #endif
00266 #ifdef __APPLE_CC__
00267 #   ifndef OSX_SYSTEM
00268 #       define  OSX_SYSTEM
00269 #   endif
00270 #   ifndef UNIX_SYSTEM
00271 #       define  UNIX_SYSTEM
00272 #   endif
00273 #   if defined (__i386__)
00274 #       define  HOOPS_BIGENDIAN     0
00275 #   else
00276 #       define  HOOPS_BIGENDIAN     1
00277 #   endif
00278 #   define  PREFERRED_RGB32     r, g, b, a
00279 #   define  RGB32_ORDER_RGBA
00280 #   define  HK_PLATFORM     "OSX"
00281 #   define  HK_PLATFORM_ID      0x400
00282 #   define  HK_DEFAULT_PICTURE  "opengl/window"
00283 #   define  USE_PTHREADS_MUTEX
00284 #endif
00285 
00286 #ifndef HK_DEFAULT_PICTURE
00287     }}}}}}}     /* force error */
00288 #endif
00289 
00290 
00291 /* do any required definitions not specified by the system block above */
00292 
00293 #ifndef HOOPS_API
00294 #       define HOOPS_API 
00295 #endif
00296 
00297 #ifndef null
00298 #ifdef __cplusplus
00299 #   define      null            0
00300 #else
00301 #   define      null            0L
00302 #endif
00303 #endif
00304 
00305 
00306 #ifndef nullroutine
00307 #   define      nullroutine     0
00308 #endif
00309 
00310 #ifndef ALIGNMENT
00311 #   define      ALIGNMENT       2               /* basic memory alignment */
00312 #endif
00313 #ifndef INT_SIZE
00314 #   define      INT_SIZE        32
00315 #endif
00316 #ifndef LONG_SIZE
00317 #   define      LONG_SIZE       32
00318 #endif
00319 #ifndef POINTER_SIZED_INT
00320 #   define      POINTER_SIZED_INT       long
00321 #endif
00322 
00323 #ifndef PREFERRED_RGB32
00324 #   define      PREFERRED_RGB32         a, b, g, r
00325 #   define      RGB32_ORDER_ABGR        
00326 #endif
00327 
00328 #ifndef HK_PLATFORM_ID
00329 #   define      HK_PLATFORM_ID          0x800   /* must be a source build */
00330 #endif
00331 
00332 #ifndef PATH_DELIMITER
00333 #   define      PATH_DELIMITER          '/'
00334 #endif
00335 #ifndef PATH_DELIMITER_TWO
00336 #   define      PATH_DELIMITER_TWO      '\0'
00337 #endif
00338 
00339 #ifndef MULTIPLE_DOT_FILENAMES
00340 #   define      MULTIPLE_DOT_FILENAMES  1       /* most systems support */
00341 #endif
00342 
00343 #ifndef HERTZ
00344 #   define      HERTZ           1000.0f             /* ticks per second */
00345 #endif
00346 
00347 #ifndef HC_CDECL
00348 #   define      HC_CDECL
00349 #endif
00350 #ifndef HF_STDCL
00351 #   define      HF_STDCL
00352 #endif
00353 
00354 
00355 #ifndef UNREFERENCED
00356 #       define UNREFERENCED(param) ((void)(param))
00357 #endif
00358 
00359 #define HK_PLATFORM_LEN 38 /* must fit MESSAGE_SIZE */
00360 
00361 
00362 #define HK_Pi                           3.141592653589793238
00363 #define DEGREES_TO_RADIANS(_deg_)       ((_deg_) * float(HK_Pi / 180.0))
00364 #define RADIANS_TO_DEGREES(_rad_)       ((_rad_) * float(180.0 / HK_Pi))
00365 
00366 /* Basic data types... */
00367 #if (INT_SIZE == 32)
00368 #  define       HT_Integer32    int
00369 #else
00370 #  define       HT_Integer32    long
00371 #endif
00372 
00373 
00374 /*****************************************************************************/
00375 /*              Determine components to enable/disable                       */
00376 
00377 /* TODO: every define in this sections should be guarded with its own ifndef */
00378 #ifdef DISABLE_MAXIMUM
00379 #   define      DISABLE_METAFILE
00380 #   define      DISABLE_TABLE_LOOKUPS
00381 #   define      DISABLE_PHONG
00382 #   define      DISABLE_TEXTURING
00383 #   define      DISABLE_SORTING_HSR
00384 #   define      DISABLE_DRAW_3D
00385 #   define      DISABLE_RASTERIZER
00386 #   define      DISABLE_DATABASE_EDIT
00387 #   define      DISABLE_GEOMETRY_EDIT
00388 #   define      DISABLE_GEOMETRY_SHOW
00389 #   define      DISABLE_SEARCH
00390 #   define      DISABLE_SHOW
00391 #   define      DISABLE_UNSET
00392 #   define      DISABLE_GEOMETRY_ATTRIBUTES
00393 #   define      DISABLE_LOD_GENERATION
00394 #   define      DISABLE_CODE_GENERATION
00395 #   define      DISABLE_DEFINED_FONTS
00396 #   define      DISABLE_EVENTS
00397 #   define      DISABLE_COLOR_NAMES
00398 #   define      DISABLE_COLOR_MAPS
00399 #   define      DISABLE_PARTIAL_ERASE
00400 #   define      DISABLE_INSTANCING
00401 #   define      DISABLE_POLY_SELECTION
00402 #   define      DISABLE_COMPUTE
00403 #   define      DISABLE_SELECTION
00404 #   define      DISABLE_BIT_RASTERS
00405 #   define      DISABLE_GRAY8_RASTERS
00406 #   define      DISABLE_MAPPED16_RASTERS
00407 #   define      DISABLE_MAPPED8_RASTERS
00408 #   define      DISABLE_STYLE_SEGMENT
00409 #   define      DISABLE_CALLBACKS
00410 #   define      DISABLE_SPECIAL_OPTIMIZATIONS
00411 #   define      DISABLE_NURBS
00412 #   define      DISABLE_CUT_GEOMETRY
00413 #   define      DISABLE_SIMPLE_SHADOW
00414 #   define      DISABLE_UNICODE_OPTIONS
00415 #   define      DISABLE_ERROR_WARNING_INFO
00416 #   define      DISABLE_NON_MANIFOLD_OPTIMIZATION
00417 #   define      DISABLE_NON_RGB_IMAGES
00418 #   define      DISABLE_EXTENDED_TEXTURE
00419 #   define      DISABLE_SOFTWARE_TEXTURE
00420 #   define      DISABLE_AIR_OPTIONS
00421 #endif
00422 
00423 #ifdef TEST_RIG_1
00424 #   define DISABLE_NON_MANIFOLD_OPTIMIZATION
00425 #   define DISABLE_NON_RGB_IMAGES
00426 #   define DISABLE_EXTENDED_TEXTURE
00427 #   define DISABLE_SOFTWARE_TEXTURE
00428 #   define DISABLE_AIR_OPTIONS
00429 #   define DISABLE_TABLE_LOOKUPS
00430 #   define DISABLE_INTERNAL_FONTS
00431 #   define DISABLE_PRIORITY
00432 #   define DISABLE_CODE_GENERATION
00433 #   define DISABLE_PARTIAL_ERASE
00434 #   define DISABLE_BIT_RASTERS
00435 #   define DISABLE_GRAY8_RASTERS
00436 #   define DISABLE_MAPPED16_RASTERS
00437 #   define DISABLE_MAPPED8_RASTERS
00438 #   define DISABLE_SPECIAL_OPTIMIZATIONS
00439 #   define DISABLE_PAINTERS
00440 #ifndef _DEBUG
00441 #   define DISABLE_ERROR_WARNING_INFO
00442 #   define DISABLE_METAFILE
00443 #   define O1_OPTIMIZATION_GUARD
00444 #endif
00445 #   define DISABLE_PHONG
00446 #   define DISABLE_LOD_GENERATION
00447 #   define DISABLE_CONTOURING
00448 #   define DISABLE_NURBS_SURFACES
00449 #   define DISABLE_EUC_JIS_UNICODE_MAPPING
00450 #   define DISABLE_RASTERIZER
00451 #   define DISABLE_BOOLEAN_COMPUTE
00452 #   define SMALL_OGL_TRISTRIP
00453 #   define DISABLE_HCD
00454 /*
00455 # define DISABLE_STYLE_SEGMENT
00456 # define DISABLE_COLOR_NAMES 
00457 # define DISABLE_SORTING_HSR
00458 # define DISABLE_DEFINED_FONTS
00459 # define DISABLE_INSTANCING
00460 #   define DISABLE_GEOMETRY_EDIT
00461 */
00462 #endif
00463  
00464 #ifdef DISABLE_SHOW
00465 #   define      DISABLE_QSHOW
00466 #   define      DISABLE_PSHOW
00467 #endif
00468 
00469 #ifdef DISABLE_NURBS
00470 #   define      DISABLE_NURBS_CURVES
00471 #   define      DISABLE_NURBS_SURFACES
00472 #endif
00473 
00474 #ifdef DISABLE_GEOMETRY_ATTRIBUTES
00475 #   define      DISABLE_GEOMETRY_COLORS
00476 #   define      DISABLE_GEOMETRY_NORMALS
00477 #   define      DISABLE_GEOMETRY_FACE
00478 #   define      DISABLE_GEOMETRY_EDGE
00479 #   define      DISABLE_GEOMETRY_MARKER
00480 #   define      DISABLE_GEOMETRY_MISC   /* ie, visibility */
00481 #endif
00482 
00483 #ifdef DISABLE_GEOMETRY_COLORS
00484 #   define      DISABLE_CONTOURING
00485 #endif
00486 
00487 
00488 #ifdef DISABLE_SORTING_HSR
00489 #   define      DISABLE_PAINTERS
00490 #   define      DISABLE_HIDDEN_LINE
00491 #   define      DISABLE_PRIORITY
00492 #endif
00493 
00494 #ifdef DISABLE_RASTERIZER
00495 #   define      DISABLE_SFB
00496 #   define      DISABLE_SZB
00497 #endif
00498 
00499 #ifdef DISABLE_DEFINED_FONTS
00500 #   define      DISABLE_INTERNAL_FONTS
00501 #endif
00502 
00503 #ifdef DISABLE_SELECTION
00504 #   define      DISABLE_SELECTION_BY_SHELL
00505 #endif
00506 
00507 
00508 /* force compiler complaint on obviously non-viable combinations */
00509 #ifdef DISABLE_COLOR_MAPS
00510 #   ifndef DISABLE_CONTOURING
00511         }}}}}}  /* CONTOURING requires COLOR_MAPS */
00512 #   endif
00513 #endif
00514 
00515 #ifdef DISABLE_DRAW_3D
00516 #   ifndef DISABLE_SORTING_HSR
00517         }}}}}}  /* SORTING_HSR requires DRAW_3D */
00518 #   endif
00519 #   ifndef DISABLE_PAINTERS
00520         }}}}}}  /* PAINTERS requires DRAW_3D */
00521 #   endif
00522 #   ifndef DISABLE_HIDDEN_LINE
00523         }}}}}}  /* HIDDEN_LINE requires DRAW_3D */
00524 #   endif
00525 #   ifndef DISABLE_PRIORITY
00526         }}}}}}  /* PRIORITY requires DRAW_3D */
00527 #   endif
00528 #   ifndef DISABLE_SZB
00529         }}}}}}  /* SZB requires DRAW_3D */
00530 #   endif
00531 #   ifndef DISABLE_SFB
00532         }}}}}}  /* SFB requires DRAW_3D */
00533 #   endif
00534 #   ifndef DISABLE_PHONG
00535         }}}}}}  /* PHONG requires DRAW_3D */
00536 #   endif
00537 #   ifndef DISABLE_SELECTION
00538         }}}}}}  /* SELECTION requires DRAW_3D */
00539 #   endif
00540 #endif
00541 
00542 
00543 
00544 #ifdef DISABLE_PHONG
00545 #   ifdef DISABLE_TEXTURING
00546 #       define DISABLE_RESHADED /* common software code paths */
00547 #   endif
00548 #endif
00549 
00550 
00551 /*****************************************************************************/
00552 
00553 /* C++ compatibility: use 'extern "C"' for all function declarations */
00554 #ifdef __cplusplus
00555 #define HPP_GLOBAL_FUNCTION             /* (default) */
00556 #define GLOBAL_FUNCTION  extern "C"
00557 #define EXTERNAL extern "C"
00558 #define UNSPECIFIED_ARGUMENTS ...
00559 #else
00560 #   define HPP_GLOBAL_FUNCTION              #error //This can only be used as C++
00561 #   define GLOBAL_FUNCTION              /* (default) */
00562 #   define EXTERNAL extern
00563 #   define UNSPECIFIED_ARGUMENTS
00564 #   define bool int
00565 #   define false 0
00566 #   define true 1
00567 #endif
00568 
00569 
00570 #define alter       /* nada */
00571 
00572 
00573 /*****************************************************************************/
00574 
00575 #ifndef DISABLE_ERROR_WARNING_INFO
00576 EXTERNAL void HC_CDECL HI_Info (int category, int specific, char const *buf);
00577 EXTERNAL void HC_CDECL HI_Info2 (int category, int specific, char const *buf1, char const *buf2);
00578 EXTERNAL void HC_CDECL HI_Info3 (int category, int specific, char const *buf1, char const *buf2, char const *buf3);
00579 EXTERNAL void HC_CDECL HI_Warning (int category, int specific, char const *buf);
00580 EXTERNAL void HC_CDECL HI_Warning2 (int category, int specific, char const *buf1, char const *buf2);
00581 EXTERNAL void HC_CDECL HI_Warning3 (int category, int specific, char const *buf1, char const *buf2, char const *buf3);
00582 EXTERNAL void HC_CDECL HI_Error (int category, int specific, char const *buf);
00583 EXTERNAL void HC_CDECL HI_Error2 (int category, int specific, char const *buf1, char const *buf2);
00584 EXTERNAL void HC_CDECL HI_Error3 (int category, int specific, char const *buf1, char const *buf2, char const *buf3);
00585 EXTERNAL void HC_CDECL HI_Fatal (int category, int specific, char const *buf);
00586 EXTERNAL void HC_CDECL HI_Fatal2 (int category, int specific, char const *buf1, char const *buf2);
00587 EXTERNAL void HC_CDECL HI_Fatal3 (int category, int specific, char const *buf1, char const *buf2, char const *buf3);
00588 EXTERNAL void HC_CDECL HI_Internal_Error (int category, int specific, char const *buf);
00589 EXTERNAL void HC_CDECL HI_Internal_Error2 (int category, int specific, char const *buf1, char const *buf2);
00590 EXTERNAL void HC_CDECL HI_Internal_Error3 (int category, int specific, char const *buf1, char const *buf2, char const *buf3);
00591 EXTERNAL void HC_CDECL HI_Internal_Data_Error (int category, int specific, char const *buf);
00592 
00593 #   define  HE_INFO(__cat__,__spec__,__buf__)   \
00594                 HI_Info(__cat__,__spec__,__buf__)
00595 #   define  HE_INFO2(__cat__,__spec__,__buf__1,__buf__2)        \
00596                 HI_Info2(__cat__,__spec__,__buf__1,__buf__2)
00597 #   define  HE_INFO3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)       \
00598                 HI_Info3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00599 #   define  HE_WARNING(__cat__,__spec__,__buf__)        \
00600                 HI_Warning(__cat__,__spec__,__buf__)
00601 #   define  HE_WARNING2(__cat__,__spec__,__buf__1,__buf__2)     \
00602                 HI_Warning2(__cat__,__spec__,__buf__1,__buf__2)
00603 #   define  HE_WARNING3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)    \
00604                 HI_Warning3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00605 #   define  HE_ERROR(__cat__,__spec__,__buf__)  \
00606                 HI_Error(__cat__,__spec__,__buf__)
00607 #   define  HE_ERROR2(__cat__,__spec__,__buf__1,__buf__2)       \
00608                 HI_Error2(__cat__,__spec__,__buf__1,__buf__2)
00609 #   define  HE_ERROR3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)      \
00610                 HI_Error3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00611 #   define  HE_FATAL(__cat__,__spec__,__buf__)  \
00612                 HI_Fatal(__cat__,__spec__,__buf__)
00613 #   define  HE_FATAL2(__cat__,__spec__,__buf__1,__buf__2)       \
00614                 HI_Fatal2(__cat__,__spec__,__buf__1,__buf__2)
00615 #   define  HE_FATAL3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)      \
00616                 HI_Fatal3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00617 #   define  HE_INTERNAL_ERROR(__cat__,__spec__,__buf__) \
00618                 HI_Internal_Error(__cat__,__spec__,__buf__)
00619 #   define  HE_INTERNAL_ERROR2(__cat__,__spec__,__buf__1,__buf__2)      \
00620                 HI_Internal_Error2(__cat__,__spec__,__buf__1,__buf__2)
00621 #   define  HE_INTERNAL_ERROR3(__cat__,__spec__,__buf__1,__buf__2,__buf__3) \
00622                 HI_Internal_Error3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00623 #   define  HE_INTERNAL_DATA_ERROR(__cat__,__spec__,__buf__)    \
00624                 HI_Internal_Data_Error(__cat__,__spec__,__buf__)
00625 #else
00626 #   define  HE_INFO(__cat__,__spec__,__buf__)
00627 #   define  HE_INFO2(__cat__,__spec__,__buf__1,__buf__2)
00628 #   define  HE_WARNING(__cat__,__spec__,__buf__)
00629 #   define  HE_WARNING2(__cat__,__spec__,__buf__1,__buf__2)
00630 #   define  HE_WARNING3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00631 #   define  HE_ERROR(__cat__,__spec__,__buf__)
00632 #   define  HE_ERROR2(__cat__,__spec__,__buf__1,__buf__2)
00633 #   define  HE_ERROR3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00634 #   define  HE_FATAL(__cat__,__spec__,__buf__)
00635 #   define  HE_FATAL2(__cat__,__spec__,__buf__1,__buf__2)
00636 #   define  HE_FATAL3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00637 #   define  HE_INTERNAL_ERROR(__cat__,__spec__,__buf__)
00638 #   define  HE_INTERNAL_ERROR2(__cat__,__spec__,__buf__1,__buf__2)
00639 #   define  HE_INTERNAL_ERROR3(__cat__,__spec__,__buf__1,__buf__2,__buf__3)
00640 #   define  HE_INTERNAL_DATA_ERROR(__cat__,__spec__,__buf__)
00641 #endif
00642 
00643 /*****************************************************************************/
00644 
00645 /* most string operations can be handled using builtins */
00646 
00647 #include        <string.h>
00648 EXTERNAL char const * HC_CDECL HI_Last_Substring_In_String (
00649                                         char const *substr, char const *string);
00650 
00651 EXTERNAL char const * HC_CDECL HI_CI_Last_Substring_In_String (
00652                                         char const *substr, char const *string);
00653 
00654 EXTERNAL char const * HC_CDECL HI_CI_First_Substring_In_String (
00655                                         char const *substr, char const *string);
00656 
00657 /* maybe allow use of builtins like stricmp()/strcasecmp() and "n" versions,
00658  * but need to see if they have incompatible "locale" issues.
00659  */
00660 #ifndef STRING_CASE_INSENSITIVE_COMPARE
00661     EXTERNAL bool HC_CDECL HI_CI_Equal_Strings (
00662                                         char const *a, char const *b);
00663 #   define STRING_CASE_INSENSITIVE_COMPARE !HI_CI_Equal_Strings
00664 #endif
00665 #ifndef STRING_CASE_INSENSITIVE_LIMITED
00666     EXTERNAL bool HC_CDECL HI_CI_Equal_Strings_To_Max (
00667                                         char const *a, int m, char const *b);
00668 #   define _CI_EQUAL_LIMITED_REORDER_(_a_,_b_,_m_) \
00669                                         HI_CI_Equal_Strings_To_Max(_a_,_m_,_b_)
00670 #   define STRING_CASE_INSENSITIVE_LIMITED !_CI_EQUAL_LIMITED_REORDER_
00671 #endif
00672 
00673 
00674 #define STRING_LENGTH(_str_)                    (int)strlen(_str_)
00675 #define COMPARE_STRINGS(_s1_,_s2_)              strcmp(_s1_,_s2_)
00676 #define COMPARE_STRINGS_LIMITED(_s1_,_m_,_s2_)  strncmp(_s1_,_s2_,_m_)
00677 #define EQUAL_STRINGS(_s1_,_s2_)                (!strcmp(_s1_,_s2_))
00678 #define EQUAL_STRINGS_LIMITED(_s1_,_m_,_s2_)    (!strncmp(_s1_,_s2_,_m_))
00679 #define CI_EQUAL_STRINGS(_s1_,_s2_)     \
00680                         (!STRING_CASE_INSENSITIVE_COMPARE(_s1_,_s2_))
00681 #define CI_EQUAL_STRINGS_LIMITED(_s1_,_s2_,_m_) \
00682                         (!STRING_CASE_INSENSITIVE_LIMITED(_s1_,_s2_,_m_))
00683 /* memcmp() like strncmp(), but doesn't need checks for null termination */
00684 #define EQUAL_MEMORY(_s1_,_m_,_s2_)             (!memcmp(_s1_,_s2_,_m_))
00685 #define COMPARE_MEMORY(_s1_,_m_,_s2_)           memcmp(_s1_,_s2_,_m_)
00686 
00687 #define COPY_STRING(_in_,_out_)                 strcpy(_out_,_in_)
00688 #define COPY_STRING_LIMITED(_in_,_m_,_out_)     \
00689                                 (strncpy(_out_,_in_,_m_), _out_[_m_ - 1] = '\0')
00690 #define APPEND_STRING(_in_,_out_)               strcat(_out_,_in_)
00691 #define APPEND_STRING_LIMITED(_in_,_m_,_out_)   strncat(_out_,_in_,_m_)
00692 
00693 #define FIRST_CHAR_IN_STRING(_chr_,_str_)       strchr(_str_,_chr_)
00694 #define LAST_CHAR_IN_STRING(_chr_,_str_)        strrchr(_str_,_chr_)
00695 #define FIRST_SUBSTRING(_sub_,_str_)    strstr(_str_,_sub_)
00696 #define LAST_SUBSTRING(_sub_,_str_)     HI_Last_Substring_In_String(_sub_,_str_)
00697 #define CI_FIRST_SUBSTRING(_sub_,_str_)     HI_CI_First_Substring_In_String(_sub_,_str_)
00698 #define CI_LAST_SUBSTRING(_sub_,_str_)      HI_CI_Last_Substring_In_String(_sub_,_str_)
00699 
00700 /* basic memory copying & setting */
00701 
00702 #ifndef COPY_MEMORY
00703 #   define      COPY_MEMORY(_src_, _siz_, _dst_)    memcpy(_dst_, _src_, _siz_)
00704 #endif
00705 #define COPY_STRUCT(_src_, _type_, _dst_)           COPY_MEMORY (_src_, sizeof(_type_), _dst_)
00706 #define COPY_ARRAY(_src_, _cnt_, _type_, _dst_)     COPY_MEMORY (_src_, (_cnt_) * sizeof(_type_), _dst_)
00707 
00708 
00709 
00710 #ifndef SET_MEMORY
00711 #   define      SET_MEMORY(_dst_, _siz_, _val_)     memset(_dst_, _val_, _siz_)
00712 #endif
00713 #define ZERO_STRUCT(_dst_, _type_)                  SET_MEMORY (_dst_, sizeof(_type_), 0)
00714 #define ZERO_ARRAY(_dst_, _cnt_, _type_)            SET_MEMORY (_dst_, (_cnt_) * sizeof(_type_), 0)
00715 
00716 
00717 /* common math/trig operations */
00718 
00719 #ifndef _INCLUDED_SYSTEM_MATH_H_
00720 #   include     <math.h>
00721 #   define      _INCLUDED_SYSTEM_MATH_H_
00722 #endif
00723 
00724 
00725 /* these need to match HEC_/HES_ values in hpserror.h */
00726 #   define      __INTERNAL_ERROR_               2
00727 #   define      __PROCEDURAL_ERROR_             2
00728 
00729 #ifndef SQRT
00730 #ifndef DISABLE_ERROR_WARNING_INFO
00731     EXTERNAL void HC_CDECL HI_Internal_Error (int category, int specific, char const *buf);
00732 #   define      SQRT(_val_)                                                   \
00733                 (_val_ >= 0.0f ? (float)sqrt(_val_) :                         \
00734                  _val_ >= -1e-20f ? 0.0f :                                \
00735                  (HE_INTERNAL_ERROR (__INTERNAL_ERROR_, __PROCEDURAL_ERROR_,  \
00736                          "Attempted square root of a negative number"), 0.0f) \
00737                 )
00738 #else
00739 #   define      SQRT(_val_)                                                   \
00740                 (_val_ >= 0.0f ? (float)sqrt(_val_) :0.0f)      
00741 #endif
00742 #endif
00743 
00744 #ifndef SINCOS
00745     EXTERNAL void HC_CDECL HI_SinCos (float angle, float *sine, float *cosine);
00746 #   define      SINCOS(_val_,_sin_,_cos)        HI_SinCos (_val_, &_sin_, &_cos)
00747 #endif
00748 
00749 #ifndef COS
00750     EXTERNAL float HC_CDECL HI_Cos (float angle);
00751 #   define      COS(_val_)              HI_Cos(_val_)
00752 #endif
00753 
00754 #ifndef ACOS
00755 #   define      ACOS(_val_)                                             \
00756                         ((_val_ > 1.0f) ? 0.0f :                        \
00757                          (_val_ < -1.0f) ? 180.0f :                     \
00758                          RADIANS_TO_DEGREES ((float)acos(_val_)))
00759 #   define      DISABLE_ARCCOSINE_LOOKUP_TABLE
00760 #endif
00761 
00762 #ifndef ATAN2
00763 #   define      ATAN2(_yy_, _xx_)                                       \
00764                         ((_xx_ == 0.0f && _yy_ == 0.0f) ? 0.0f :        \
00765                          RADIANS_TO_DEGREES((float)atan2(_yy_, _xx_)))
00766 #   define      DISABLE_ARCTANGENT_INTERNAL_CODE
00767 #endif
00768 
00769 
00770 /* "bug" in stupid AIX headers */
00771 #ifdef AIX_SYSTEM
00772 #  ifdef index
00773 #     undef index  /* so 'index' can be used as a variable name in structs */
00774 #  endif
00775 #endif
00776 
00777 /*****************************************************************************/
00778 
00779 /* go get the structure tags BEFORE actually starting to define
00780  * anything. Various sick compilers require this ordering.
00781  */
00782 #include "tags.h"
00783 
00784 #include "hoops_memory.h"
00785 
00786 // EXTERNAL C FUNCTION TYPES
00787 
00788 EXTERNAL {
00789 /* Generic function pointers (for relaxing HC arguments) */
00790 typedef void (HC_CDECL * HT_Void_Routine) (UNSPECIFIED_ARGUMENTS);
00791 typedef int (HC_CDECL * HT_Int_Routine) (UNSPECIFIED_ARGUMENTS);
00792 
00793 typedef bool (HC_CDECL * HT_Driver_Action)(HT_Driver *driver,int request);
00794 
00795 typedef HT_Driver_Action (HC_CDECL * HT_Load_Dynamic_Driver_Action)(char const *driver_name);
00796 
00797 typedef void (HC_CDECL * HT_Event_Checker_Action) (void);
00798 
00799 }
00800 
00801 
00802 // NOT EXTERNAL C++ FUNCTION TYPES
00803 //namespace HOOPS {
00804 typedef void (HC_CDECL * HT_Segment_Iterator_Action) (HT_Segment alter *seg, void alter *info);
00805 void HC_CDECL HPP_For_Each (char const *spec, bool required, HT_Segment_Iterator_Action action, void *param);
00806 
00807 #if 0
00808 typedef void (HC_CDECL * HPP_Old_Triangle_Action)
00809                 (void *info, HT_Integer32 convex_triangulation,
00810                  HT_Integer32 v1, HT_Integer32 v2, HT_Integer32 v3);
00811 
00812 typedef void (HC_CDECL * HPP_Triangle_Action)
00813                 (void *info, int convex_triangulation,
00814                  HT_Point const *v1,
00815                  HT_Point const *v2,
00816                  HT_Point const *v3,
00817                  int s1,
00818                  int s2,
00819                  int s3,
00820                  HT_Intersection const *d1,
00821                  HT_Intersection const *d2,
00822                  HT_Intersection const *d3);
00823 
00824 bool HC_CDECL HPP_Triangulate_Face (HT_Point const *points,
00825          HT_Vector const *normal,
00826          int const *face_list,
00827          int const *face_list_end,
00828          HPP_Old_Triangle_Action triangle_action,
00829          void *action_info);
00830 
00831 bool HC_CDECL HPP_Triangulate_Face_X (HT_Point const *points,
00832          HT_Vector const *normal,
00833          int const *face_list,
00834          int const *face_list_end,
00835          HPP_Triangle_Action triangle_action,
00836          void *action_info);
00837 #endif
00838 //}
00839 
00840 typedef void (HC_CDECL *HT_System_Cleanup_Hook_Action)(void);
00841 
00842 typedef int (HC_CDECL * HT_Transform_And_Test_Action)
00843     (HT_Transform_Rendition const *tr,
00844        int point_count,
00845        HT_Point const *in,
00846        float const *matrix,
00847        HT_Rectangle const *clip,
00848        HT_DC_Point alter *out,
00849        float alter *ws,
00850        unsigned char alter *clip_case);
00851 
00852 typedef HT_Attribute alter * (HC_CDECL * HT_Attribute_Acquisitor_Action)(HT_Segment alter *seg,HT_Attribute const *old,void const *info);
00853 
00854 
00855 #   define      TOASCII(c)      (c)
00856 
00857 
00858 /* for bit masks, where true/false really aren't appropriate */
00859 #define NOTHING         0
00860 #define EVERYTHING      (-1)
00861 
00862 #define MAX_ERRMSG              16530   /* (number of characters) */
00863 #define MAX_SPRINTF_BUF         16530   /* (number of characters) */
00864 #define MAX_FLOAT               1e30f
00865 #define MAX_FLOAT_LOG10         30
00866 #define MAX_PATHNAME            500     /* (number of characters) */
00867 #define MAX_CHAR                0x7F    /* minimum amongst all machines */
00868 #define MAX_UCHAR               0xFF    /* minimum amongst all machines */
00869 #define MAX_SHORT               (short)(((unsigned short)~0L)>>1)
00870 #define MAX_INT                 (int)(((unsigned int)~0L)>>1)
00871 #define MAX_LONG                (long)(((unsigned long)~0L)>>1)
00872 #define MAX_USHORT              ((unsigned short)~0L)
00873 #define SQRT_MAX_FLOAT          1e15f
00874 
00875 
00876 
00877 #define ALIAS_HASH_SIZE                 128
00878 #define CALLBACK_NAMES_HASH_SIZE         64
00879 #define FONTS_HASH_SIZE                  64
00880 #define TEXTURE_NAME_HASH_SIZE           32
00881 #define COLOR_NAME_HASH_SIZE            128
00882 #define KEY_HASH_SIZE                   512
00883 
00884 
00885 struct HT_Option_Hash_Table {
00886     HT_Option_Type          **  table;
00887     int                         size;
00888     int                         count;
00889 };
00890 
00891 #define CALLBACK_OPTIONS_HASH            0
00892 #define CAMERA_PROJECTION_HASH           1
00893 #define COLOR_HASH                       2
00894 #define CONDITIONS_HASH                  3
00895 #define DRIVER_OPTIONS_HASH              4
00896 #define HEURISTICS_HASH                  5
00897 #define METAFILE_HASH                    6
00898 #define RENDERING_OPTIONS_HASH           7
00899 #define SELECTABILITY_HASH               8
00900 #define TEXT_FONT_HASH                   9
00901 #define TEXTURE_OPTION_HASH             10
00902 #define USER_OPTIONS_HASH               11
00903 #define USER_KOPTIONS_HASH              12
00904 #define VISIBILITY_HASH                 13
00905 
00906 #define AREA_LIGHT_HASH                 14
00907 #define CYLINDER_CAP_OPTION_HASH        15
00908 #define IMAGE_HASH                      16
00909 #define SPOT_LIGHT_HASH                 17
00910 #define TEXT_ENCODING_HASH              18
00911 #define TEXT_REGION_HASH                19
00912 #define GEOMETRY_OPTION_HASH            20
00913 #define GEOMETRY_POINTER_OPTION_HASH    21
00914 
00915 #define SYSTEM_INFO_HASH                22
00916 #define SYSTEM_OPTIONS_HASH             23
00917 #define FONT_OPTIONS_HASH               24
00918 #define FONT_SEARCH_HASH                25
00919 #define SHOW_FONT_HASH                  26
00920 
00921 #define CONTENTS_SEARCH_HASH            27
00922 #define BOUNDING_FILTER_HASH            28
00923 #define BOOLEAN_OPTIONS_HASH            29
00924 #define MINIMIZE_OPTIONS_HASH           30
00925 #define UPDATE_CONTROL_OPTIONS_HASH     31
00926 
00927 #define CHARACTER_ATTRIBUTE_OPTIONS_HASH 32
00928 #define DRIVER_CONFIG_HASH              33
00929 #define DISTANCE_SELECTION_OPTIONS_HASH 34
00930 
00931 #define OPTIMIZE_TREE_HASH              35
00932 #define COLOR_CHANNEL_HASH              36
00933 #define CURVE_OPTION_HASH               37
00934 #define GENERATE_SHELL_HASH             38
00935 #define POINTS_INSIDE_SHELL_HASH        39
00936 
00937 #define WINDOW_FRAME_HASH               40  
00938 
00939 #define MAX_OPTION_HASH_TABLES          41
00940  
00941 
00942 
00943 #define globaldata      /* (default) */
00944 #define local           static  /* local data should be 'const' too! */
00945 
00946 #ifndef forever
00947 #   define forever      while (1)
00948 #endif
00949 #ifndef until
00950 #   define until(x)     while (!(x))
00951 #endif
00952 #ifndef countof
00953 #   define countof(x)   (int)(sizeof(x)/sizeof(x[0]))
00954 #endif
00955 #ifndef nobreak
00956 #   define nobreak      /* (fall through -- instead of break) */
00957 #endif
00958 
00959 
00960 /* utility stuff (MIN and MAX defined later on) */
00961 #ifndef SGN
00962 # define SGN(a)         ((a) == 0 ? 0 : (a) < 0 ? -1 : 1)
00963 #endif
00964 #ifndef ABS
00965 # define ABS(a)         ((a) < 0 ? -(a) : (a))
00966 #endif
00967 #ifndef FABS
00968 # define FABS(a)        ((a) < 0.0f ? -(a) : (a))
00969 #endif
00970 #ifndef FLOOR
00971 # define FLOOR(a)       (((a) > 0.0f || (float)(int)(a) == (a)) ? (int)(a) : ((int)(a) - 1))
00972 #endif
00973 #ifndef CEILING
00974 # define CEILING(a)     (((a) < 0.0f || (float)(int)(a) == (a)) ? (int)(a) : ((int)(a) + 1))
00975 #endif
00976 #define BIT(v, mask)    (((v) & (mask)) != 0)
00977 #define SIGNED_CHARTOINT(c)     (((int)(char)-1 == -1) ? \
00978                                  (int)(char)(c) : \
00979                                  (UNSIGNED_CHARTOINT(c) & 0x80) ? \
00980                                   UNSIGNED_CHARTOINT(c) - 256 : \
00981                                  UNSIGNED_CHARTOINT(c))
00982 #define UNSIGNED_CHARTOINT(c)   (((int)(unsigned char)0xFF == 0xFF) ? \
00983                          (int)(unsigned char)(c) : (0xFF & (int)(c)))
00984 #define UNSIGNED_CHARTOLONG(c)  (((long)(unsigned char)0xFF == 0xFF) ? \
00985                          (long)(unsigned char)(c) : (0xFF & (long)(c)))
00986 #define HM_TOLOWER(c)   EVERY(to_lower)[UNSIGNED_CHARTOINT(c)]
00987 #define ALLBITS(v, mask) (((v) & (mask)) == (mask))
00988 #define ANYBIT(v, mask) (((v) & (mask)) != 0)
00989 #define LOWBIT(v)       ((long)(v) & -(long)(v))
00990 
00991 #define EQUAL_NAMES(a,b)                        \
00992                 ((a).length == (b).length && ((a).length == 0 || \
00993                  EQUAL_MEMORY ((a).text, (a).length, (b).text)))
00994 #define EQUAL_KNAMES(a,b)                       \
00995                 ((a).length == (b).length && ((a).length == 0 || \
00996                  EQUAL_MEMORY ((a).ktext, (a).length*sizeof(HT_Karacter), (b).ktext)))
00997 
00998 
00999 
01000 typedef POINTER_SIZED_INT       HT_Key;
01001 #define POINTER_SIZED_HIGHBIT   (POINTER_SIZED_INT)((unsigned POINTER_SIZED_INT)1 << (int)(8 * sizeof (POINTER_SIZED_INT) - 1))
01002 #define V2I(x) ((POINTER_SIZED_INT)(x))
01003 #define I2V(x) ((void *)(POINTER_SIZED_INT)(x))
01004 
01005 
01006 /*** assumes a pointer can map into a negative long ***/
01007 EXTERNAL HT_Anything * HC_CDECL HI_Key_To_Pointer (HT_Key key,
01008                                                      HT_Segment *seg);
01009 #define POINTER_TO_KEY(p)  ((((HT_Key)p)>>1) | POINTER_SIZED_HIGHBIT)
01010 #define KEY_TO_POINTER(key)     KEY_TO_POINTER_SCOPED (key,null)
01011 #define KEY_TO_POINTER_SCOPED(key,seg)  ((key) < ERROR_KEY ? \
01012                                  (HT_Anything *)((key)<<1) : \
01013                                  HI_Key_To_Pointer(key,seg))
01014 #define ERROR_KEY               (-1L)
01015 
01016 
01017 #define RANDOM()        (OUR(random) *= (int)69069, ++OUR(random))
01018 #define URANDOM()       ((unsigned int)RANDOM())
01019 
01020 #define SEMI_PROTECT(x) do {x} while (0)    /* (';' missing on purpose) */
01021 
01022 /* some compilers/settings complain if macro arguments are unused,
01023  * the following provides a means of indicating that the argument is
01024  * "referenced" without side effects such as performing function calls
01025  */
01026 #define DO_NOTHING(x)   do if (0 && (x)) {} while (0)
01027 
01028 EXTERNAL void HC_CDECL HI_Start_Hoops (char const *function_name);
01029 
01030 #ifdef DISABLE_CODE_GENERATION
01031 #   define CODE_GENERATION(x_code_x) do {} while (0)
01032 #else
01033     EXTERNAL void HC_CDECL HI_Dump_Code (char const *string);
01034     EXTERNAL void HC_CDECL HI_Chain_Code_Files (void);
01035 #   define CODE_GENERATION(x_code_x)                                    \
01036     do if (BIT (OUR (system_flags), Sysop_GENERATE_CODE)) {             \
01037         HT_Thread_Specific_Data *_thread_data_;                         \
01038         FIND_THREAD_DATA (_thread_data_);                               \
01039         if (_thread_data_->current_routine_sp ==                        \
01040                         _thread_data_->current_routine_stack) {         \
01041             H_LOCK_MUTEX_LOW (OUR (code_generation_mutex));             \
01042             { x_code_x }                                                \
01043             if (OUR (code_lines) > OUR (code_line_limit))               \
01044                 HI_Chain_Code_Files ();                                 \
01045             H_UNLOCK_MUTEX_LOW (OUR (code_generation_mutex));           \
01046         }                                                               \
01047     } while (0)
01048 #endif
01049 
01050 /* compatible with types in hmutex.h but using Hoops prefered naming */
01051 typedef void *  HT_Mutex;
01052 typedef void *  HT_Lock;
01053 
01054 #define HMUTEX_ERROR(_m_)   HE_INTERNAL_ERROR2 (0, 0, "Multithreading control error", _m_)
01055 
01056 
01057 #include "hmutex.h"
01058 
01059 
01060 #define H_LOCK_MUTEX_LOW(x)                                     \
01061             do {                                                \
01062                 if (OUR (concurrency) >= Concurrency_LOW)       \
01063                     LOCK_MUTEX (x);                             \
01064             } while (0)
01065 #define H_UNLOCK_MUTEX_LOW(x)                                   \
01066             do {                                                \
01067                 if (OUR (concurrency) >= Concurrency_LOW)       \
01068                     UNLOCK_MUTEX (x);                           \
01069             } while (0)
01070 #define H_LOCK_MUTEX_FULL(x)                                    \
01071             do {                                                \
01072                 if (OUR (concurrency) == Concurrency_FULL)      \
01073                     LOCK_MUTEX (x);                             \
01074             } while (0)
01075 #define H_UNLOCK_MUTEX_FULL(x)                                  \
01076             do {                                                \
01077                 if (OUR (concurrency) == Concurrency_FULL)      \
01078                     UNLOCK_MUTEX (x);                           \
01079             } while (0)
01080 
01081 #define H_READ_LOCK(x)                                          \
01082             do {                                                \
01083                 if (OUR (concurrency) == Concurrency_FULL)      \
01084                     READ_LOCK (x);                              \
01085             } while (0)
01086 #define H_WRITE_LOCK(x)                                         \
01087             do {                                                \
01088                 if (OUR (concurrency) == Concurrency_FULL)      \
01089                     WRITE_LOCK (x);                             \
01090             } while (0)
01091 #define H_UNLOCK_LOCK(x)                                        \
01092             do {                                                \
01093                 if (OUR (concurrency) == Concurrency_FULL)      \
01094                     UNLOCK_LOCK (x);                            \
01095             } while (0)
01096 
01097 
01098 #define H_READ_DATABASE()       H_READ_LOCK(OUR(database_lock))
01099 #define H_WRITE_DATABASE()      H_WRITE_LOCK(OUR(database_lock))
01100 #define H_RELEASE_DATABASE()    H_UNLOCK_LOCK(OUR(database_lock))
01101 
01102 #define NAMEKEY(name, key) do { \
01103         (key)=0; \
01104         if ((name).length > 0) { \
01105             int iiiii; for (iiiii=0;iiiii<(name).length;iiiii++) (key)+=(name).text[iiiii]; \
01106             (key) = (((key)<<8)|(((name).length&0xFF))); \
01107         } \
01108     } while (0)
01109 
01110 #define INITNAME(name)  do { (name).length = 0;(name).text = 0; \
01111                         } while (0)
01112 
01113 #define INITKNAME(name) do { (name).length = 0;(name).ktext = 0; \
01114                         } while (0)
01115 
01116 #define NAMEFREE(name)  do if ((name).length > 0) {     \
01117                             FREE_ARRAY((name).text, (name).length+1, char); \
01118                             INITNAME(name); \
01119                         } while (0)
01120 #define KNAMEFREE(name) do if ((name).length > 0) {     \
01121                             FREE_ARRAY((name).ktext, (name).length+1, HT_Karacter); \
01122                             INITKNAME(name); \
01123                         } while (0)
01124 
01125 
01126 
01127 /* define MIN and MAX here rather than earlier in the file because
01128  * some system headers define their own (compatible) macros */
01129 #ifndef MIN
01130 # define MIN(a, b)      ((a) < (b) ? (a) : (b))
01131 #endif
01132 #ifndef MAX
01133 # define MAX(a, b)      ((a) > (b) ? (a) : (b))
01134 #endif
01135 
01136 
01137 
01138 
01139 typedef unsigned short          HT_Color_Index;
01140 typedef float                   HT_Color_Float_Index;
01141 
01142 typedef HT_Integer32    HT_Type_Flags;
01143 typedef HT_Integer32    HT_Heuristics_Flags;
01144 typedef HT_Integer32    HT_Activity;
01145 typedef int             HT_Button;
01146 typedef HT_Integer32    HT_Parameter_Flags;
01147 typedef char            HT_Generic_Size_Units;
01148 
01149 
01150 typedef unsigned HT_Integer32 HT_Utility;       /* used for database objects */
01151 typedef unsigned HT_Integer32 HT_Reference_Count;       /* for anything else */
01152 
01153 
01154 
01155 #ifndef NO_SHARING
01156 #  define IS_SHARED(ref)  ((ref)->refcount > 1)
01157 #else
01158 #  define IS_SHARED(ref)  true
01159 #endif
01160 
01161 
01162 typedef float HT_Row_Vector[4];
01163 typedef unsigned char HT_Matrix_Flags;
01164 typedef unsigned char HT_Matrix_Contents;
01165 
01166 struct HT_Matrix {
01167 
01168     HT_Row_Vector       elements[4];
01169     HT_Row_Vector       adjoint[4];
01170 
01171     HT_Reference_Count  refcount;
01172     HT_Integer32        incarnation;
01173 
01174     float               symmetric_scale;
01175 
01176 #   define Matrix_Contents_NONE         (HT_Matrix_Contents)0x00
01177 #   define Matrix_Contents_ROTATION     (HT_Matrix_Contents)0x01
01178 #   define Matrix_Contents_SCALE        (HT_Matrix_Contents)0x02
01179 #   define Matrix_Contents_TRANSLATION  (HT_Matrix_Contents)0x04
01180 #   define Matrix_Contents_PERSPECTIVE  (HT_Matrix_Contents)0x08
01181 #   define Matrix_Contents_3D           (HT_Matrix_Contents)0x10
01182 #   define Matrix_Contents_NEG3X3       (HT_Matrix_Contents)0x20 /* only maintained in limited circumstances */
01183 #   define Matrix_Contents_ANYTHING     (HT_Matrix_Contents)0xFF
01184     HT_Matrix_Contents  contents;
01185 
01186 #   define Matrix_ADJOINT_VALID (HT_Matrix_Flags)0x01
01187     HT_Matrix_Flags     flags;
01188 
01189 };
01190 
01191 
01192 struct HT_XY {
01193     float               x, y;
01194 };
01195 
01196 
01197 struct HT_Point {
01198     float               x, y, z;
01199 };
01200 
01201 #define COPY_POINT(src, dest) ((dest) = (src))
01202 
01203 #define INIT_POINT(p) \
01204         ((p).x = (p).y = (p).z = 0.0f)
01205 
01206 struct HT_Vector {
01207     float               x, y, z;
01208 };
01209 
01210 #define COPY_VECTOR(src, dest) ((dest) = (src))
01211 
01212 
01213 struct HT_Plane {
01214     float               a, b, c, d;
01215 };
01216 
01217 #define COPY_PLANE(src, dest) ((dest) = (src))
01218 
01219 #define INIT_PLANE(p) \
01220         ((p).a = (p).b = (p).c = (p).d = 0.0f)
01221 
01222 
01223 typedef float HT_Parameter;
01224 
01225 #define COPY_PARAMETER(src, dest, width) \
01226         COPY_MEMORY((src), (width)*sizeof(HT_Parameter), (dest))
01227 
01228 #define COPY_N_PARAMETERS(src, dest, width, count) \
01229         COPY_MEMORY((src), (count)*(width)*sizeof(HT_Parameter), (dest))
01230 
01231 #define GET_PARAMETER(vp, offset, out, width) do { \
01232         COPY_PARAMETER(&(vp)[(offset)*(width)], (out), width); \
01233     } while (0)
01234 
01235 #define INIT_PARAMETER(param,width) \
01236         SET_MEMORY((param), (width)*sizeof(HT_Parameter), 0)
01237 
01238 #define INIT_N_PARAMETERS(param,count,width) \
01239         SET_MEMORY((param), (count)*(width)*sizeof(HT_Parameter), 0)
01240 
01241 
01242 struct HT_Rectangle {
01243     float               left, right, bottom, top;
01244 };
01245 
01246 struct HT_Volume {
01247     float               left, right, bottom, top, hither, yon;
01248 };
01249 
01250 
01251 typedef int HT_Test;
01252 #define Test_DISJOINT               (HT_Test)0
01253 #define Test_INSCRIBED              (HT_Test)1
01254 #define Test_INTERSECTING           (HT_Test)2
01255 #define Test_EXTENT                 (HT_Test)4
01256 #define Test_INSCRIBED_EXTENT       (HT_Test)(Test_INSCRIBED | Test_EXTENT)
01257 #define Test_INTERSECTING_EXTENT    (HT_Test)(Test_INTERSECTING | Test_EXTENT)
01258 
01259 typedef short HT_Bounding_Type;
01260 #define Bounding_UNKNOWN        (HT_Bounding_Type)0
01261 #define Bounding_RECTANGLE      (HT_Bounding_Type)1
01262 #define Bounding_CUBOID         (HT_Bounding_Type)2
01263 #define Bounding_SPHERE         (HT_Bounding_Type)3
01264 
01265 typedef short HT_Bounding_Flags;
01266 #define Bounding_EMPTY                  (HT_Bounding_Flags)0x0001
01267 #define Bounding_LOCKED                 (HT_Bounding_Flags)0x0002
01268 #define Bounding_EXCLUDED               (HT_Bounding_Flags)0x0004
01269 #define Bounding_TEXT                   (HT_Bounding_Flags)0x0010
01270 #define Bounding_IMAGE                  (HT_Bounding_Flags)0x0020
01271 #define Bounding_TRANSFORM_DEPENDENT    (HT_Bounding_Flags)0x0040   /* other than text/image */
01272 #define Bounding_CUBOID_VALID_RADIUS    (HT_Bounding_Flags)0x0080   /* radius evaluated lazily for cuboids */
01273 
01274 struct HT_Bounding_Header {
01275     HT_Bounding_Type    type;
01276     HT_Bounding_Flags   flags;
01277 };
01278 
01279 struct HT_Bounding_Cuboid {
01280     HT_Bounding_Header          h;
01281     HT_Point                    min, max; /* "max" needs to immediately follow "min" */
01282     float                       radius;   /* the distance from centroid to corners */
01283 };
01284 
01285 struct HT_Bounding_Rectangle {
01286     HT_Bounding_Header          h;
01287     float                       left, right,
01288                                 bottom, top;
01289 };
01290 
01291 struct HT_Bounding_Sphere {
01292     HT_Bounding_Header          h;
01293     HT_Point                    center;
01294     float                       radius;
01295 };
01296 
01297 union HT_Bounding {
01298     HT_Bounding_Header          h;
01299     HT_Bounding_Rectangle       rectangle;
01300     HT_Bounding_Cuboid          cuboid;
01301     HT_Bounding_Sphere          sphere;
01302 };
01303 
01304 typedef HT_Integer32    HT_HFSB_Flags;  
01305 
01306 #define HFSB_IGNORE_VISIBILITY      0x0001
01307 #define HFSB_DETAILED               0x0002
01308 #define HFSB_SKIP_SHADOW_POINTS     0x0004
01309 #define HFSB_CRUDE                  0x0008
01310 #define HFSB_OBEY_EXCLUDE           0x0010
01311 #define HFSB_EXCLUDE_CAMERA         0x0020
01312 #define HFSB_WANT_EXCLUDE           0x0040
01313 
01314 #define DECIPHER_POLY_VALUES(_count_, _bump_, _natural_) do {                       \
01315             if (_count_ > 0) {  _count_ -= (_natural_ - 1); _bump_ = 1;         }   \
01316             else {              _count_ /= -(_natural_);    _bump_ = _natural_; }   \
01317         } while (0)
01318 
01319 /* make it pointer sized so that HT_Name aligns nicely */
01320 typedef POINTER_SIZED_INT HT_Name_Length;
01321 
01322 struct HT_Name {
01323     char                *text;
01324     HT_Name_Length      length;
01325 };
01326 
01327 struct HT_Name_Const {
01328     char const          *text;
01329     HT_Name_Length      length;
01330 };
01331 
01332 /* Note: NAME() should be used only for initializing constant structures   */
01333 /* however, since we also use HT_Name as a variable-sized string class,    */
01334 /* we can't use (char const *) in the class.  Instead, we can use at least */
01335 /* use (char * const) to make sure the target structure is declared const  */
01336 #define NAME(s)         {(char * const)s,sizeof(s)-1}   /* initializer for a 'HT_Name' */
01337 #define NONAME          {null, 0}
01338 
01339 struct HT_Name_List {
01340     HT_Name             name;
01341     HT_Integer32        key;
01342     HT_Name_List        *next;
01343 };
01344 
01345 /* "Karacters" are extended 16-bit (or more) characters. If the upper
01346  * byte(s) are all zeroes, the character code is Ascii, in the low
01347  * bytes. If the upper isn't all zeroes, then it's something else,
01348  * like Kanji or extended ISO fonts.
01349  */
01350 
01351 typedef unsigned short  HT_Karacter;
01352 
01353 struct HT_KName {
01354     HT_Karacter         *ktext;
01355     HT_Name_Length      length;
01356 };
01357 
01358 
01359 
01360 #define HASH_STRING(_p_, _t_, _h_) do {                         \
01361             _t_ const * _str_ = (_t_ const *)(_p_); \
01362             unsigned long   _hash_ = 5381;          \
01363             int             _c_;                    \
01364             if (_str_) while ((_c_ = (int)*_str_++) != 0)       \
01365                 _hash_ = ((_hash_ << 5) + _hash_) ^ _c_;        \
01366             _h_ = _hash_;                                       \
01367         } while (0)
01368 #define HASH_CHARS(_s_, _h_)    HASH_STRING(_s_, unsigned char, _h_)
01369 #define HASH_KARS(_s_, _h_)     HASH_STRING(_s_, HT_Karacter, _h_)
01370 #define HASH_NAME(_n_, _h_)     HASH_CHARS ((_n_).text, _h_)
01371 #define HASH_KNAME(_n_, _h_)    HASH_KARS ((_n_).ktext, _h_)
01372 
01373 
01374 
01375 
01376 
01377 struct HT_HLS {
01378     float               hue, lightness, saturation;
01379 };
01380 
01381 
01382 
01383 struct HT_RGB {
01384     float               red, green, blue;
01385 };
01386 
01387 union HT_RGB_HSL{
01388     HT_RGB rgb;
01389     HT_HLS hls;
01390 };
01391 
01392 #define INIT_RGB(rgb) \
01393         ((rgb).red = (rgb).green = (rgb).blue = 0.0f)
01394 
01395 
01396 #define COPY_RGB(src, dest) ((dest) = (src))
01397 
01398 struct HT_RGB24 {
01399     unsigned char       r, g, b;
01400 };
01401 
01402 struct HT_Int_RGB {
01403     int                 r, g, b;
01404 };
01405 
01406 struct HT_Int32_RGB {
01407     HT_Integer32                r, g, b;
01408 };
01409 
01410 
01411 #define TRANSPARENCY_TO_ALPHA(t)        ((int)(255.99f * (1.0f - t)))
01412 #define COMPLETELY_OPAQUE_ALPHA         0xFF
01413 
01414 /* THIS 'rgb32' SHOULD BE IDENTICAL TO A 'HT_Local_Vertex_Attributes->rgb'!
01415  * (there's a drawing optimization that depends on it!)
01416  */
01417 union HT_RGBAS32 {
01418     HT_Integer32                whole_thing;
01419     struct {
01427         unsigned char   PREFERRED_RGB32;
01428     }                   rgb;
01429 };
01430 
01431 struct HT_RGBA {
01432     float               red, green, blue, alpha;
01433 };
01434 
01435 #define INIT_RGBA(rgba) \
01436         ((rgba).red = (rgba).green = (rgba).blue = (rgba).alpha = 0.0f)
01437 
01438 #define COPY_RGBA(src, dest) ((dest) = (src))
01439 
01440 #define COPY_RGB_TO_RGBA(src, new_alpha, dest) \
01441         ((dest).red = (src).red, (dest).green = (src).green, (dest).blue = (src).blue, (dest).alpha = new_alpha)
01442 
01443 struct HT_RGBA32 {
01444     unsigned char       r, g, b, a;
01445 };
01446 
01447 #define COPY_RGBA32(src, dest) \
01448         *(HT_Integer32*)&dest = *(HT_Integer32*)&src
01449 
01450 #define RGB_TO_RGBAS32(_rgb, alpha, rgb32) (                                \
01451         (rgb32).rgb.r = (unsigned char)(255.99f * (_rgb).red),      \
01452         (rgb32).rgb.g = (unsigned char)(255.99f * (_rgb).green),        \
01453         (rgb32).rgb.b = (unsigned char)(255.99f * (_rgb).blue),     \
01454         (rgb32).rgb.a = alpha)
01455 
01456 #define RGBAS32_TO_RGB(rgb32, _rgb)     (                                  \
01457         (_rgb).red   = (float)UNSIGNED_CHARTOINT((rgb32).rgb.r)*(1.00001f/255.0f), \
01458         (_rgb).green = (float)UNSIGNED_CHARTOINT((rgb32).rgb.g)*(1.00001f/255.0f), \
01459         (_rgb).blue  = (float)UNSIGNED_CHARTOINT((rgb32).rgb.b)*(1.00001f/255.0f))
01460 
01461 #define RGBAS32_TO_RGBA32(_rgbas32, _rgba32) (  \
01462         (_rgba32).r = (_rgbas32).rgb.r,     \
01463         (_rgba32).g = (_rgbas32).rgb.g,     \
01464         (_rgba32).b = (_rgbas32).rgb.b,     \
01465         (_rgba32).a = (_rgbas32).rgb.a)
01466 
01467 #define RGBA_TO_RGBAS32(_rgb, mixalpha, rgbas32) (                          \
01468         (rgbas32).rgb.r = (unsigned char)(255.99f * (_rgb).red),        \
01469         (rgbas32).rgb.g = (unsigned char)(255.99f * (_rgb).green),      \
01470         (rgbas32).rgb.b = (unsigned char)(255.99f * (_rgb).blue),       \
01471         (rgbas32).rgb.a = (unsigned char)((mixalpha + 0.99f) * (_rgb).alpha))
01472 
01473 #define RGBAS32_TO_RGBA(rgb32, _rgba)       (                                  \
01474         (_rgba).red   = (float)UNSIGNED_CHARTOINT((rgb32).rgb.r)*(1.00001f/255.0f), \
01475         (_rgba).green = (float)UNSIGNED_CHARTOINT((rgb32).rgb.g)*(1.00001f/255.0f), \
01476         (_rgba).blue  = (float)UNSIGNED_CHARTOINT((rgb32).rgb.b)*(1.00001f/255.0f), \
01477         (_rgba).alpha = (float)UNSIGNED_CHARTOINT((rgb32).rgb.a)*(1.00001f/255.0f))
01478 
01479 struct HT_ARGB32 {
01480     unsigned char       a, r, g, b;
01481 };
01482 
01483 
01484 #define INIT_RGBAS32(p)         ((p).whole_thing = 0)
01485 #define COPY_RGBAS32(src, dest) ((dest).whole_thing = (src).whole_thing)
01486 
01487 
01488 typedef int     HT_Material_Components;
01489 #define M_NONE                  (HT_Material_Components)0x0000
01490 #define M_DIFFUSE               (HT_Material_Components)0x0001
01491 #define M_GENERIC_COLOR         M_DIFFUSE   /* before assignment to specific channel */
01492 #define M_SPECULAR              (HT_Material_Components)0x0002
01493 #define M_MIRROR                (HT_Material_Components)0x0004
01494 #define M_TRANSMISSION          (HT_Material_Components)0x0008
01495 #define M_EMISSION              (HT_Material_Components)0x0010
01496 
01497 #define M_GLOSS                 (HT_Material_Components)0x0020
01498 #define M_INDEX                 (HT_Material_Components)0x0040
01499 
01500 #define M_DIFFUSE_TEXTURE       (HT_Material_Components)0x0100
01501 #define M_GENERIC_TEXTURE       M_DIFFUSE_TEXTURE /* before assignment to specific channel */
01502 #define M_SPECULAR_TEXTURE      (HT_Material_Components)0x0200
01503 #define M_MIRROR_TEXTURE        (HT_Material_Components)0x0400
01504 #define M_TRANSMISSION_TEXTURE  (HT_Material_Components)0x0800
01505 #define M_EMISSION_TEXTURE      (HT_Material_Components)0x1000
01506 
01507 #define M_BUMP_TEXTURE          (HT_Material_Components)0x2000
01508 #define M_ENVIRONMENT_TEXTURE   (HT_Material_Components)0x4000
01509 
01510 #define M_ANY_TEXTURE           (HT_Material_Components)0xFF00
01511 #define M_ANY_COLOR             (HT_Material_Components)0x001F
01512 
01513 #define M_LOCKABLE              (HT_Material_Components)0x607F
01514 
01515 
01516 #define Color_Type_FRONT                 0
01517 #define Color_Type_BACK                  1
01518 #define Color_Type_FACE_CONTRAST         2
01519 #define Color_Type_EDGE                  3
01520 #define Color_Type_EDGE_CONTRAST         4
01521 #define Color_Type_LINE                  5
01522 #define Color_Type_LINE_CONTRAST         6
01523 #define Color_Type_MARKER                7
01524 #define Color_Type_MARKER_CONTRAST       8
01525 #define Color_Type_VERTEX                9
01526 #define Color_Type_VERTEX_CONTRAST      10
01527 #define Color_Type_TEXT                 11
01528 #define Color_Type_TEXT_CONTRAST        12
01529 #define Color_Type_WINDOW               13
01530 #define Color_Type_WINDOW_CONTRAST      14
01531 #define Color_Type_CUT_EDGE             15
01532 #define Color_Type_CUT_FACE             16
01533 #define Color_Type_SIMPLE_REFLECTION    17
01534 #define Color_Type_LIGHTING             18
01535 #define Color_Type_AMBIENT              19
01536 
01537 #define Color_Type_MATERIAL_COUNT       18
01538 #define Color_Type_TOTAL_COUNT          20
01539 
01540 /* need to match HIC_Color_Lock_Objects */
01541 typedef int     HT_Color_Object;
01542 #define Color_NONE              (HT_Color_Object)0x00000000
01543 #define Color_FRONT             (HT_Color_Object)(1<<Color_Type_FRONT)
01544 #define Color_BACK              (HT_Color_Object)(1<<Color_Type_BACK)
01545 #define Color_FACE_CONTRAST     (HT_Color_Object)(1<<Color_Type_FACE_CONTRAST)
01546 #define Color_EDGE              (HT_Color_Object)(1<<Color_Type_EDGE)
01547 #define Color_EDGE_CONTRAST     (HT_Color_Object)(1<<Color_Type_EDGE_CONTRAST)
01548 #define Color_LINE              (HT_Color_Object)(1<<Color_Type_LINE)
01549 #define Color_LINE_CONTRAST     (HT_Color_Object)(1<<Color_Type_LINE_CONTRAST)
01550 #define Color_MARKER            (HT_Color_Object)(1<<Color_Type_MARKER)
01551 #define Color_MARKER_CONTRAST   (HT_Color_Object)(1<<Color_Type_MARKER_CONTRAST)
01552 #define Color_VERTEX            (HT_Color_Object)(1<<Color_Type_VERTEX)
01553 #define Color_VERTEX_CONTRAST   (HT_Color_Object)(1<<Color_Type_VERTEX_CONTRAST)
01554 #define Color_TEXT              (HT_Color_Object)(1<<Color_Type_TEXT)
01555 #define Color_TEXT_CONTRAST     (HT_Color_Object)(1<<Color_Type_TEXT_CONTRAST)
01556 #define Color_WINDOW            (HT_Color_Object)(1<<Color_Type_WINDOW)
01557 #define Color_WINDOW_CONTRAST   (HT_Color_Object)(1<<Color_Type_WINDOW_CONTRAST)
01558 #define Color_CUT_EDGE          (HT_Color_Object)(1<<Color_Type_CUT_EDGE)
01559 #define Color_CUT_FACE          (HT_Color_Object)(1<<Color_Type_CUT_FACE)
01560 #define Color_SIMPLE_REFLECTION (HT_Color_Object)(1<<Color_Type_SIMPLE_REFLECTION)
01561 #define Color_LIGHTING          (HT_Color_Object)(1<<Color_Type_LIGHTING)
01562 #define Color_AMBIENT           (HT_Color_Object)(1<<Color_Type_AMBIENT)
01563 
01564 #define Color_FACE              (Color_FRONT|Color_BACK)
01565 #define Color_POLYGON           (Color_FACE|Color_EDGE)
01566 #define Color_GEOMETRY          (Color_POLYGON|Color_LINE|Color_MARKER|Color_VERTEX|Color_TEXT)
01567 #define Color_CUT_GEOMETRY      (Color_CUT_FACE|Color_CUT_EDGE)
01568 
01569 #define Color_CONTRASTS         (Color_FACE_CONTRAST|Color_EDGE_CONTRAST|Color_LINE_CONTRAST|\
01570                                  Color_MARKER_CONTRAST|Color_VERTEX_CONTRAST|Color_TEXT_CONTRAST|\
01571                                  Color_WINDOW_CONTRAST)
01572 
01573 #define Color_EVERYTHING        (Color_WINDOW|Color_GEOMETRY|Color_CUT_GEOMETRY|Color_CONTRASTS|\
01574                                  Color_LIGHTING|Color_AMBIENT)
01575 
01576 #define INIT_MATERIAL(mat) do { \
01577     (mat).rgb.red = (mat).rgb.green = (mat).rgb.blue = 0.0f; \
01578 }while (0)
01579 
01580 #define EQUAL_MATERIAL(one, two) \
01581     ((one).rgb.red   == (two).rgb.red && \
01582     (one).rgb.green == (two).rgb.green && \
01583     (one).rgb.blue  == (two).rgb.blue)     
01584 
01585 /* the following two items don't include diffuse, which is in a separate linked list */
01586 #define MAT_TEXTURE_COUNT 6  
01587 #define MAT_COLOR_COUNT 4
01588 
01589 #define MAT_SPECULAR        0
01590 #define MAT_MIRROR          1
01591 #define MAT_TRANSMISSION    2
01592 #define MAT_EMISSION        3
01593 #define MAT_BUMP            4
01594 #define MAT_ENVIRONMENT     5
01595 
01596 typedef unsigned int HT_Material_Channel_Flags;
01597 #define MCF_None                (HT_Material_Channel_Flags)0x0000
01598 #define MCF_Modulate_Color      (HT_Material_Channel_Flags)0x0001  /* modulate the texture by its attenuation_color */
01599 #define MCF_Explicit            (HT_Material_Channel_Flags)0x0002  /* textures must exactly match definitions */
01600 #define MCF_Tail_Extend         (HT_Material_Channel_Flags)0x0004  /* propagate to all subsequent channels */
01601 #define MCF_Modulate_From_Diffuse   (HT_Material_Channel_Flags)0x0008  /* if modulating the texture use the diffuse_color */
01602 
01603 struct HT_Texture_Control_List {
01604     HT_Texture_Control_List     *next;
01605     HT_Texture                  *texture;
01606     HT_Name                     name;
01607     float                       opacity;
01608     int                         order;
01609     HT_Material_Channel_Flags   flags;
01610 };
01611 
01612 struct HT_Named_Material {
01613     HT_Texture                  *texture[MAT_TEXTURE_COUNT];  /* non-diffuse channels only */
01614     HT_Texture_Control_List     *diffuse_textures;
01615     HT_RGB_HSL                  diffuse_color;
01616     HT_Name                     diffuse_name;
01617     HT_RGB_HSL                  color[MAT_COLOR_COUNT];
01618     HT_Name                     name[MAT_COLOR_COUNT];
01619     HT_Material_Channel_Flags   flags[MAT_COLOR_COUNT];
01620 
01621     int                         combined_color_flags;
01622 
01623     float                       gloss,
01624                                 index_of_refraction,
01625                                 opacity;
01626     HT_Material_Components      components;
01627 };
01628 
01629 
01630 /* integer/pointer pair used for User_Option_By_Index */
01631 
01632 struct HT_Indexed_User_Option {
01633     long                index;
01634     void                *value;
01635 };
01636 
01637 typedef float           HT_Time;
01638 #define TIME(sec)       ((HT_Time)(HERTZ*(sec)))  /* Seconds to ticks */
01639 #define POLL_INTERVAL   TIME(1.0/100.0)
01640 
01641 typedef short               HT_Type;
01642 
01643 #define Error_Control_OFF   0
01644 #define Error_Control_ON    1
01645 #define Error_Control_ONCE  2
01646 
01647 typedef int                     HT_Error_Mask;
01648 
01649 struct HT_Error_Control {
01650     HT_Error_Control            *next;
01651     int                         category,
01652                                 specific;
01653     short                       setting,    /* provided by user */
01654                                 state;      /* setting, except once -> off after use */
01655 };
01656 
01657 
01658 
01659 typedef char                    HT_Text_Encoding;
01660 
01661 typedef unsigned HT_Integer32   HT_Drivo_Flags;
01662 typedef unsigned HT_Integer32   HT_Rendo_Flags;
01663 typedef HT_Integer32            HT_Rendo_Debug;
01664 
01665 typedef int                     HT_Technology_Flags,
01666                                 HT_Radiosity_Flags,
01667                                 HT_Ray_Trace_Flags,
01668                                 HT_Quantization_Flags,
01669                                 HT_HSR_Algorithm,
01670                                 HT_Buffer_Flags,
01671                                 HT_Hidden_Line_Flags,
01672                                 HT_LOD_Flags,
01673                                 HT_NURBS_Curve_Flags,
01674                                 HT_NURBS_Surface_Flags,
01675                                 HT_Tessellation_Flags,
01676                                 HT_Cut_Geometry_Flags,
01677                                 HT_Simple_Shadow_Flags,
01678                                 HT_Shadow_Map_Flags,
01679                                 HT_Simple_Reflection_Flags,
01680                                 HT_Color_Depth;
01681 
01682 typedef HT_Integer32            HT_Depth;
01683 typedef char                    HT_Image_Format;
01684 #define Image_NONE              (HT_Image_Format)0
01685 #define Image_MAPPED_8          (HT_Image_Format)1
01686 #define Image_MAPPED_16         (HT_Image_Format)2
01687 #define Image_RGB24             (HT_Image_Format)3
01688 #define Image_ARGB32            (HT_Image_Format)4
01689 #define Image_RGBA32            (HT_Image_Format)5
01690 #define Image_DEPTH_FLOAT32     (HT_Image_Format)6
01691 /* internal framebuffer format */
01692 #define Image_RGBAS32           (HT_Image_Format)7
01693 /* other internal formats */
01694 #define Image_DEPTH16           (HT_Image_Format)8
01695 #define Image_STENCIL           (HT_Image_Format)9
01696 #define Image_DEPTH32           (HT_Image_Format)10
01697 
01698 
01699 /* Image source types */
01700 #define Image_Source_COPY                               0
01701 #define Image_Source_BY_REF                             1
01702 #define Image_Source_BY_ROW                             2
01703 #define Image_Source_DRIVER_CREATED_FRAME_BUFFER        3
01704 #define Image_Source_SYSTEM_CREATED_FRAME_BUFFER        4
01705 #define Image_Source_IMAGE                              5
01706 #define Image_Source_NONE                               6
01707 
01708 typedef int             HT_Polygon_Rank;
01709 #define Polygon_SIMPLE                  (HT_Polygon_Rank)0x00
01710 #define Polygon_CONCAVE                 (HT_Polygon_Rank)0x01
01711 #define Polygon_SELF_INTERSECTING       (HT_Polygon_Rank)0x02
01712 
01713 
01714 /* the next 40 lines are here in hoops.h only because of the need to make
01715  * "open_list_terminator" fully declared... */
01716 typedef unsigned short          HT_Database_Flags;
01717 
01718 #define DB_DELETED              (HT_Database_Flags)0x0001 /* for anything */
01719 #define DB_OUT_OF_ORDER         (HT_Database_Flags)0x0002 /* for geom, inc, seg */
01720 #define DB_MAY_BE_3D            (HT_Database_Flags)0x0004 /* for geom, matrix, cam */
01721 #define DB_ALREADY_SEEN         (HT_Database_Flags)0x0008 /* mostly seg, misc */
01722 #define DB_BOUNDING             (HT_Database_Flags)0x0010 /* segments & geometry */
01723 #define DB_NAUGHTY_BIT          (HT_Database_Flags)0x0020 /* segments & geometry */
01724 #define DB_TEMPORARY            (HT_Database_Flags)0x0040 /* temp geometry */
01725 
01726 #define DB_TYPE_SPECIFIC(v)     (HT_Database_Flags)(1 << (7+(v)))   /* currently top 8 reserved bits numbered 1-8 */
01727 
01728 typedef int             HT_Open_Type;
01729 struct HT_Open_Item {
01730     struct {
01731         HT_Open_Item            *next,
01732                                 **backlink;
01733         HT_World                *owner;
01734         HT_Utility              utility;
01735         HT_Type                 type;
01736         HT_Database_Flags       dbflags;
01737     }                   h;
01738 
01739     HT_Open_Type                open_type;
01740 #   define      Open_NONE       (HT_Open_Type)0
01741 #   define      Open_GEOMETRY   (HT_Open_Type)1
01742 #   define      Open_EDGE       (HT_Open_Type)2
01743 #   define      Open_VERTEX     (HT_Open_Type)3
01744 #   define      Open_FACE       (HT_Open_Type)4
01745 #   define      Open_SEGMENT    (HT_Open_Type)5
01746 #   define      Open_LOD        (HT_Open_Type)6
01747 #   define      Open_TRIM       (HT_Open_Type)7
01748 #   define      Open_REGION     (HT_Open_Type)8
01749 
01750 
01751     union {
01752         struct {
01753 #           define      Open_Item_SEGMENT_NO_CLOSE      DB_TYPE_SPECIFIC(1)
01754             HT_Segment          *referee;
01755             HT_Segment          *original_referee;
01756             HT_Polyline         *inked_line;
01757         }                   segment;
01758 
01759         struct {
01760             HT_Geometry         *referee;
01761             int                         offset;
01762         }                   geometry;
01763 
01764         struct {
01765             HT_Polyhedron           *referee;
01766             int                         offset;
01767         }                   polyhedron;
01768 
01769         struct {
01770             HT_Anything         *referee;
01771             int                         offset;
01772         }                   lod;
01773 
01774         struct {
01775             HT_NURBS_Surface        *referee;
01776             int                         offset;
01777         }                   nurbs_surface;
01778     }                   info;
01779 };
01780 
01781 #define MAX_C_RETURN_STRING_LENGTH      (1L<<20)    /* 1MB */
01782 
01783 
01784 
01785 #define XBIT_SIZE   2
01786 
01787 #define XBIT_BIT(item)      (item%32)
01788 #define XBIT_OFFSET(item)   (item/32)
01789 
01790 #define XBIT_TEST(a,b) (((a)[XBIT_OFFSET(b)] & (1<<XBIT_BIT(b))) != 0)
01791 
01792 typedef HT_Integer32 HT_Driver_Config_Flags;
01793 
01794 #define HTDF_NONE       (HT_Driver_Config_Flags)0x00000000 
01795 #define HTDF_SOFTWARE   (HT_Driver_Config_Flags)0x00000001
01796 
01797 struct HT_Driver_Config {
01798     HT_Name     driver;
01799     HT_Name     id;
01800     HT_Name     version;
01801 
01802     HT_Driver_Config_Flags flags;
01803 
01804     HT_Integer32    xbits[XBIT_SIZE];
01805 
01806     HT_Name_List    *config;
01807     
01808     int         tristrips_min;
01809     int         dl_tristrips_min;
01810     int         flat_tristrips_min;
01811     int         flat_dl_tristrips_min;
01812 
01813     HT_Driver_Config * next;
01814 };
01815 
01816 
01817 struct HT_Selection_Event_CD {
01818     HT_Point hit_location;
01819 };
01820 
01821 
01822 struct HT_XBits {
01823     const char      *options;
01824     HT_Integer32    bit;    
01825 };
01826 
01827 
01828 #define OPTIMIZED_MAPPING_HASH_SIZE 256
01829 
01830 struct HT_Optimized_Mapping {
01831     HT_Optimized_Mapping        *forward;
01832     HT_Optimized_Mapping        *backward;
01833     struct {
01834         HT_Key                  owner;
01835         HT_Key                  key;
01836         int                     region;
01837     } original,
01838                                 optimized;
01839 };
01840 
01841 struct HT_Optimized_Mapping_Table {
01842     HT_Optimized_Mapping_Table      *next;
01843     HT_Segment const                *segment;
01844     HT_Optimized_Mapping            *forward[OPTIMIZED_MAPPING_HASH_SIZE];
01845     HT_Optimized_Mapping            *backward[OPTIMIZED_MAPPING_HASH_SIZE];
01846 };
01847 
01848 typedef struct ht_key_hash {
01849     HT_Key_List                 **table;
01850     HT_Integer32                size;
01851     HT_Integer32                entries;
01852 } HT_Key_Hash;
01853 
01854 
01855 #define     Sysop_DS_NO_UPDATE_CONTROL          0x0001 
01856 
01857 struct HT_Definition_Set {
01858     HT_Segment  const           *texture_root;
01859     HT_Alias                    **alias_hash_table;
01860     HT_Font                     **defined_fonts_hash_table;
01861     HT_Color_Name               **color_names_hash_table;
01862     HT_Color_Def                *color_defs;
01863     HT_Callback_Name            **callback_names_hash_table;    
01864     HT_VHash                    *color_material_lookup;
01865     HT_Key_Hash                 global_keys;
01866     HT_Name                     metafile_root;
01867     int                         flags;
01868 };
01869 
01870 struct HT_Thread_Specific_Data {
01871     HT_Thread_Specific_Data     *next;
01872 
01873     char const                  *current_routine,
01874                                 *current_routine_stack[20], /* (20 is large!) */
01875                                 **current_routine_sp;
01876     
01877     HT_VHash                    *seg_path_lookup;
01878 
01879     HT_Search_Header            *segment_search_stack,
01880                                 *contents_search_stack,
01881                                 *alias_search_stack,
01882                                 *callback_search_stack,
01883                                 *color_search_stack,
01884                                 *open_search_stack,
01885                                 *font_search_stack,
01886                                 *texture_search_stack,
01887                                 *glyph_search_stack,
01888                                 *line_style_search_stack;
01889 
01890     HT_Event                    *event_queue,
01891                                 *newest_event,
01892                                 *current_event;
01893     HT_Selection_Event_CD       *cd_event;
01894 
01895     void                        *shell_selection_cache;
01896     void                        *intersect_polyline_cache;
01897     void                        *point_inside_shell_cache;
01898     void                        *boolean_data;
01899     
01900     /* context-sensitive stuff */
01901     HT_Open_Item                *open_list; 
01902     HT_Open_Item                open_list_terminator;
01903 
01904     HThreadID                   owner;
01905     
01906     /* these need to be isolated per-thread */
01907     char                        sprintf_buffer[MAX_SPRINTF_BUF];
01908 
01909     int                         error_severity;
01910     int                         error_category;
01911     int                         error_specific;
01912 
01913     /* thread-specific update info */
01914     int                         update_status;
01915     HT_Time                     update_start_time;
01916     HT_Time                     update_end_time;
01917     int                         update_end_time_check;
01918 
01919     volatile bool               timer_expired;
01920     volatile HT_Time            time_stamp;
01921 
01922     int                         definition_set_id;
01923 };
01924 
01925 
01926 
01927 
01928 struct HT_World {
01929     struct {
01930         HT_World                *next,
01931                                 **backlink;
01932         void                    *owner;         /* harrumph */
01933         HT_Utility              utility;
01934         HT_Type                 type;
01935         HT_Database_Flags       dbflags;        /* (matches HT_Segment dbflags) */
01936     }                           h;
01937 
01938     bool                        started;
01939 
01940     bool                        reseting;
01941     bool                        called_exit;
01942 
01943 
01944 
01945     HT_Thread_Specific_Data     main_thread;
01946     HT_Thread_Specific_Data     *recent_thread;
01947 
01948     HT_Definition_Set           *definition_sets;
01949     int                         definition_set_count;
01950 
01951     int                         hoops_version;
01952 
01953     bool                        no_auto_stream;
01954 
01955     HT_Memory_Pool              *memory_pool;
01956 
01957     HT_Driver                   *driver_list;
01958     HT_Driver                   *isolated_drivers;
01959     HT_Segment                  *root;
01960     int                         random;
01961 
01962     HT_Key_Hash                 local_keys;
01963 
01964     HT_Error_Handler            *error_handler_list;
01965     HT_Exit_Handler             *exit_handler_list;
01966     HT_Error_Handler            *error_handler_save;
01967     bool                        error_handler_ever_defined;
01968     bool                        exit_handling;
01969 
01970     HT_Name                     fortran_bufs[6];
01971 
01972     unsigned char               *dither_patterns4;
01973     unsigned char               *dither_patterns8;
01974     unsigned short              *dither_patterns16;
01975 
01976     long                        next_priority;
01977 
01978     HT_Option_Hash_Table        option_hash_tables[MAX_OPTION_HASH_TABLES];
01979 
01980     HT_Option_Type              **conditions_lookup;
01981     int                         conditions_count;
01982 
01983     int                         next_user_option_id;
01984 
01985     HT_Wakeup                   *wakeup_list;
01986     void                        *system_time_data; 
01987 
01988     bool                        request_location_first_time;
01989     int                         timer_enables;
01990 
01991     HT_Callback_Name            *event_checker_name;
01992 
01993     HT_Event_Checker_Action         event_checker;
01994 
01995     HT_Transform_And_Test_Action    hd_transform_and_test[6];
01996     
01997     HT_System_Cleanup_Hook_Action   system_cleanup_hook;
01998 
01999     HT_Load_Dynamic_Driver_Action   dynamic_driver_loader;
02000     
02001 
02002     HT_Integer32                update_generation;
02003     bool                        update_events_needed;
02004     bool                        update_needed;
02005     int                         update_suspensions;
02006     HT_Metafile                 *metafile_write_list;
02007 
02008     void                        *system_specific_data;
02009 
02010     /* system options... */
02011     HT_Error_Mask               error_mask;
02012     HT_Error_Control *          error_control[4];   /* info, warning, error, fatal */
02013     int                         C_return_string_length;
02014     HT_Name                     application;    /* word boundary */
02015     HT_Text_Encoding            encoding;       /* word+1 boundary */
02016     char                        junk1;          /* back to longword boundary */
02017     int                         message_limit,
02018                                 messages_given;
02019 
02020 #   define      SYS_DEBUG_PRINT_VERSION                     0x00000001
02021 #   define      SYS_DEBUG_SHOW_MEMORY_USAGE                 0x00000002
02022 #   define      SYS_DEBUG_BREAK_TO_DEBUGGER                 0x00000004
02023 #   define      SYS_DEBUG_DISABLE_TRISTRIP_QUADS            0x00000100
02024 #   define      SYS_DEBUG_FALSE_COLOR_TRISTRIPS             0x00000200
02025 #   define      SYS_DEBUG_SHOW_TRISTRIP_STATISTICS          0x00000400
02026 #   define      SYS_DEBUG_DISABLE_NON_MANIFOLD_OPT          0x00000800
02027 #   define      SYS_DEBUG_TRISTRIP_HEX_TRIANGLE             0x00001000
02028 #   define      SYS_DEBUG_OLD_NURBS_SURFACE_TESSELLATION    0x00002000
02029 #   define      SYS_DEBUG_SUBSTRIP_LARGE_FACES              0x00004000
02030 #   define      SYS_DEBUG_DISABLE_FAST_SEGMENT_LOOKUP       0x00008000
02031 #   define      SYS_DEBUG_QUICK_MEM_LOGGING                 0x00010000
02032     int                         debug;
02033 
02034 #   define      Sysop_CONTINUOUS_UPDATE         0x0001
02035 #   define      Sysop_OBSOLETE_CHECKING         0x0002
02036 #   define      Sysop_SANITY_CHECKING           0x0004
02037 #   define      Sysop_UNUSED_1                  0x0008 
02038 #   define      Sysop_BOUNDING_VOLUMES          0x0010
02039 #   define      Sysop_GENERATE_CODE             0x0020
02040 #   define      Sysop_CONSISTENT_NORMALS        0x0040
02041 #   define      Sysop_CONSERVE_MEMORY           0x0080
02042 #   define      Sysop_SHELL_RESTRIP_ON_EDIT     0x0100
02043 #   define      Sysop_OLD_STYLE_PATHNAMES       0x0200
02044 #   define      Sysop_TRISTRIP_PER_REGION       0x0400
02045 #   define      Sysop_LEGACY_MESH_NUMBERING     0x0800
02046 #   define      Sysop_LEGACY_TEXT_EXTENT_X      0x1000
02047 #   define      Sysop_NEAR_LIMIT_UPDATE_PROMOTION 0x2000
02048     int                         system_flags;
02049 
02050 #   define      Conserve_NONE                   0x0000
02051 #   define      Conserve_SHELL_FACE_LIST        0x0001
02052 #   define      Conserve_SCREEN_PLANE_FACINGS   0x0002
02053 #   define      Conserve_LIGHTWEIGHT_CIRCLES    0x0004
02054 #   define      Conserve_POLYEDGES              0x0008
02055 #   define      Conserve_EVERYTHING             0x000F
02056     int                         conserve_flags;
02057 
02058 #   define      Warn_Once_AIR                   0x0001
02059 #   define      Warn_Once_IM                    0x0002
02060 #   define      Warn_Once_PICTURE_ALIAS         0x0004
02061 #   define      Warn_Once_IM_MISMATCH           0x0010
02062 #   define      Warn_Once_NO_CLASSIC            0x0020
02063 #   define      Warn_Once_SWZ_WITH_DOUBLEBUFF   0x0040
02064 #   define      Warn_Once_SWZ_WITH_FORCEBW      0x0080
02065 #   define      Warn_Once_USE_DISABLED          0x0200
02066 
02067     int                         warnings_given;
02068 
02069 
02070     void                        *air_passthru;
02071     HT_Integer32                rand48_seed;
02072     HT_Pending_Special          *pending_special_events;
02073     HT_Pending_Redraw           *pending_redraws;
02074 
02075 
02076     void                        *kanji_data;
02077     HT_Driver_Config            *driver_config_data;
02078 
02079     /* move the rest, if any, up when convenient... */
02080 
02081     bool                        print_version_ok_on_start;
02082 
02083     int                         string_history_limit;
02084 
02085     HT_Name_List                *font_directory;
02086     bool                        skip_extended_font_search;
02087 
02088     /*global_font_data for font processors*/
02089     void                        *global_font_data_freetype;
02090 
02091     void                        *font_stencil_cache;
02092 
02093     void                        *code_file;
02094     int                         code_file_number;
02095     int                         code_lines;
02096     int                         code_line_limit;
02097     int                         code_indent_level;
02098     bool                        code_beginning_of_line;
02099 
02100 #   define      License_AIR     0x0001
02101 #   define      License_IM      0x0002
02102 #   define      License_KANJI   0x0004
02103 #   define      License_CLASSIC 0x0008
02104 #   define      License_HSF     0x0010
02105     int                         license;
02106 
02107     HT_Name_List                *driver_directory;
02108     HT_Name_List                *metafile_directory;
02109 
02110     bool                        override_license_messages;
02111     bool                        expand_instances;
02112     unsigned int                next_unused_display_list_id;
02113 
02114 #define Concurrency_NONE        0
02115 #define Concurrency_LOW         1
02116 #define Concurrency_FULL        2
02117     int                         concurrency;
02118     HT_Mutex                    memory_mutex;
02119     HT_Mutex                    utility_mutex;
02120     HT_Mutex                    thread_mutex;
02121     HT_Mutex                    hash_mutex;
02122     HT_Mutex                    code_generation_mutex;
02123     HT_Mutex                    polyhedron_mutex;
02124     HT_Mutex                    driver_mutex;
02125     HT_Mutex                    font_instance_mutex;
02126     HT_Lock                     database_lock;
02127 
02128 #define Processor_NONE          0x00000000
02129 #define Processor_MMX           0x00000001
02130 #define Processor_SSE           0x00000002
02131 #define Processor_SSE2          0x00000004
02132 #define Processor_SSE3          0x00000008
02133 #define Processor_3DNow         0x00000100
02134 #define Processor_3DNow_DSP     0x00000200
02135 #define Processor_MMX_EXT       0x00000400
02136     int                         processor_capabilities;
02137     int                         original_processor_capabilities;
02138     int                         processor_override;
02139     unsigned int                mxcsr_capabilities;
02140 
02141     float const                 *sinlookup72;
02142 
02143     unsigned int                display_list_vram_usage;
02144     unsigned int                texture_vram_usage;
02145     unsigned int                vram_usage_limit;
02146     unsigned int                vram_size;
02147 
02148     unsigned int                transparent_image_count;
02149 
02150 
02151     HT_Optimized_Mapping_Table  *optimized_mapping_tables;
02152     HT_VHash                    *hcd_table;
02153 
02154     float                       camera_near_limit;
02155 
02156     HT_Image                    *texture_fallback_image;
02157 
02158     unsigned int                raw_memory_usage;
02159 #ifdef VALIDATE_MEMORY
02160     FILE*                       quick_mem_logging_file;
02161 #endif
02162 };
02163 
02164 
02165 struct HT_World_Read_Only {
02166     unsigned short              dither_thresholds[8][8];
02167 
02168     int                         incr_mod_4[4];
02169     int                         incr_mod_8[8];
02170     int                         incr_mod_16[16];
02171     short                       power2[16];
02172     int                         numbits[64];
02173     unsigned char               reversed_byte[256];
02174 
02175     char                        to_lower[256];
02176 
02177     float                       uniform_rand[1024];
02178     float                       gaussian_rand[2048];
02179 
02180     float                       char_to_float[256];
02181 
02182     char const                  *disabled_message;
02183 
02184     HT_Material_Components  material_color_components[MAT_COLOR_COUNT];
02185     HT_Material_Components  material_locked_components[MAT_TEXTURE_COUNT];
02186     HT_Material_Components  material_texture_components[MAT_TEXTURE_COUNT];
02187 
02188 };
02189 
02190 #define CHEAPRAND()     (OUR(rand48_seed) < 0 ? (OUR(rand48_seed) = (OUR(rand48_seed) ^ RANDKEY) | 1) : (OUR(rand48_seed) ^= RANDKEY))
02191 #define UNIRAND()       (EVERY(uniform_rand[++OUR(rand48_seed) & 0x3FF]))
02192 #define GAUSSRAND()     (EVERY(gaussian_rand[++OUR(rand48_seed) & 0x7FF]))
02193 #define CHAR_TO_FLOAT(x) (EVERY(char_to_float[UNSIGNED_CHARTOINT(x)]))
02194 
02195 
02196 EXTERNAL HT_Thread_Specific_Data * HC_CDECL HI_Find_Thread_Specific_Data (unsigned POINTER_SIZED_INT);
02197 #define H_THREAD_DATA(thread_id)        HI_Find_Thread_Specific_Data (thread_id)
02198 
02199 #define FIND_THREAD_DATA(_thread_data_) do {                            \
02200             HThreadID current_thread;                                   \
02201             _thread_data_ = OUR(recent_thread);                         \
02202             if (OUR (concurrency) != Concurrency_NONE &&                \
02203                     (_thread_data_->owner != (current_thread=THREAD_ID()))) \
02204                 _thread_data_ = H_THREAD_DATA (current_thread);         \
02205         } while (0)
02206 
02207 #define SETNAME(x)                                      \
02208         do if (!US() || !OUR(started)) {                \
02209             HI_Start_Hoops (x);                         \
02210         }                                               \
02211         else {                                          \
02212             HT_Thread_Specific_Data     *_thread_data_; \
02213             FIND_THREAD_DATA (_thread_data_);           \
02214             _thread_data_->current_routine = (x);       \
02215             if (_thread_data_->current_routine_sp ==    \
02216                 _thread_data_->current_routine_stack) { \
02217                 _thread_data_->error_severity = -1;     \
02218                 _thread_data_->error_category = -1;     \
02219                 _thread_data_->error_specific = -1;     \
02220             }                                           \
02221         } while (0)
02222 #define PUSHNAME()      do {                            \
02223             HT_Thread_Specific_Data     *_thread_data_; \
02224             FIND_THREAD_DATA (_thread_data_);           \
02225             *_thread_data_->current_routine_sp =        \
02226                 _thread_data_->current_routine;         \
02227             ++_thread_data_->current_routine_sp;        \
02228         } while (0)
02229 #define POPNAME()       do {                            \
02230             HT_Thread_Specific_Data     *_thread_data_; \
02231             FIND_THREAD_DATA (_thread_data_);           \
02232             _thread_data_->current_routine =            \
02233                 *--_thread_data_->current_routine_sp;   \
02234         } while (0)
02235 
02236 
02237 
02238 EXTERNAL bool HC_CDECL HC_Update_Display (void);
02239 #define HI_Suspend_Updates()    (++OUR(update_suspensions))
02240 
02241 
02242 #define HI_Resume_Updates()     do {                            \
02243         if (--OUR(update_suspensions) == 0 &&                   \
02244             BIT (OUR(system_flags), Sysop_CONTINUOUS_UPDATE) && \
02245             OUR(update_needed))  {                              \
02246                 PUSHNAME(); HC_Update_Display (); POPNAME();    \
02247         }                                                       \
02248     }   while (0)
02249 
02250 
02251 EXTERNAL char * HC_CDECL HI_Sprintf4 (char *buf, char const *spec,
02252                                      int int1, int int2,
02253                                      void const *ptr1, void const *ptr2);
02254 #define Sprintf_D(buf,spec,a)    HI_Sprintf4(buf,spec,a,0,null,null)
02255 #define Sprintf_S(buf,spec,a)    HI_Sprintf4(buf,spec,0,0,(void*)a,null)
02256 #define Sprintf_QS(buf,spec,a)   HI_Sprintf4(buf,spec,0,0,(void*)a,null)
02257 #define Sprintf_P(buf,spec,a)    HI_Sprintf4(buf,spec,0,0,(void*)a,null)
02258 #define Sprintf_K(buf,spec,a)    HI_Sprintf4(buf,spec,0,0,(void*)a,null)
02259 #define Sprintf_N(buf,spec,a)    HI_Sprintf4(buf,spec,0,0,(void*)a,null)
02260 #define Sprintf_QN(buf,spec,a)   HI_Sprintf4(buf,spec,0,0,(void*)a,null)
02261 #define Sprintf_F(buf,spec,a)    HI_Sprintf4(buf,spec,0,0,(void*)&a,null)
02262 #define Sprintf_LD(buf,spec,a)   HI_Sprintf4(buf,spec,0,0,(void*)&a,null)
02263 #define Sprintf_X(buf,spec,a)    HI_Sprintf4(buf,spec,0,0,(void*)&a,null)
02264 #define Sprintf_NN(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02265 #define Sprintf_FF(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)&a,(void*)&b)
02266 #define Sprintf_SF(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)&b)
02267 #define Sprintf_SS(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02268 #define Sprintf_SD(buf,spec,a,b) HI_Sprintf4(buf,spec,b,0,(void*)a,null)
02269 #define Sprintf_ND(buf,spec,a,b) HI_Sprintf4(buf,spec,b,0,(void*)a,null)
02270 #define Sprintf_SP(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02271 #define Sprintf_PS(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02272 #define Sprintf_SN(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02273 #define Sprintf_NS(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02274 #define Sprintf_PP(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02275 #define Sprintf_PN(buf,spec,a,b) HI_Sprintf4(buf,spec,0,0,(void*)a,(void*)b)
02276 #define Sprintf_DD(buf,spec,a,b) HI_Sprintf4(buf,spec,a,b,null,null)
02277 #define Sprintf_DF(buf,spec,a,b) HI_Sprintf4(buf,spec,a,0,(void*)&b,null)
02278 
02279 #ifndef EXCLUDE_HOOPS_WORLD
02280 /* global fixed data (such as it is) */
02281 
02282 EXTERNAL HOOPS_API HT_World *   _HOOPS;
02283 #define US()            (_HOOPS)
02284 #define OUR(whatever)   _HOOPS->whatever
02285 
02286 #define MY_DS(_x_) (OUR(definition_sets)[thread_data->definition_set_id]._x_)
02287 
02288 EXTERNAL HOOPS_API HT_World_Read_Only   _HOOPS_READ_ONLY;
02289 #define EVERY(whatever) _HOOPS_READ_ONLY.whatever
02290 
02291 
02292 #endif
02293 
02294 
02295 
02296 /* Cast away constness! This is not thread-safe. */
02297 #define REALLY_INCR_UTILITY(ref) (++*(HT_Reference_Count alter *)&((ref)->refcount))
02298 #define REALLY_DECR_UTILITY(ref) (--*(HT_Reference_Count alter *)&((ref)->refcount))
02299 #define ZERO_UTILITY(ref) ((ref)->refcount = 0)
02300 
02301 /* #define DEBUG_UTILITY */
02302 #if defined(DEBUG_UTILITY) && !defined(EXCLUDE_HOOPS_WORLD)
02303 
02304 #  ifdef WINDOWS_SYSTEM
02305 #    include <stdio.h>
02306 #    define INCR_UTILITY(ref) \
02307     sprintf (OUR(debug_scratch), "+%p %d->%d %s %d\n", (void*)(ref), (ref)->refcount, (ref)->refcount+1, __FILE__, __LINE__),\
02308     OutputDebugString (OUR(debug_scratch)),\
02309     (REALLY_INCR_UTILITY(ref))
02310 #    define DECR_UTILITY(ref) \
02311     sprintf (OUR(debug_scratch), "-%p %d->%d %s %d\n", (void*)(ref), (ref)->refcount, (ref)->refcount-1, __FILE__, __LINE__),\
02312     OutputDebugString (OUR(debug_scratch)),\
02313     (REALLY_DECR_UTILITY(ref))
02314 #    define INIT_UTILITY(ref) (((ref)->refcount = 0), INCR_UTILITY (ref))
02315 
02316 #  else
02317 
02318 #    include <stdio.h>
02319 #    define INCR_UTILITY(ref) \
02320     printf ("+%p %d->%d %s %d\n", (void*)(ref), (ref)->refcount, (ref)->refcount+1, __FILE__, __LINE__),\
02321     (REALLY_INCR_UTILITY(ref))
02322 #    define DECR_UTILITY(ref) \
02323     printf ("-%p %d->%d %s %d\n", (void*)(ref), (ref)->refcount, (ref)->refcount-1, __FILE__, __LINE__),\
02324     (REALLY_DECR_UTILITY(ref))
02325 #    define INIT_UTILITY(ref) (((ref)->refcount = 0), INCR_UTILITY (ref))
02326 #  endif
02327 
02328 #elif defined (VALIDATE_MEMORY)
02329 
02330 #   define INCR_UTILITY(ref) ((((ref)->refcount)==0x55555555) ? (HE_ERROR(0, 0, "detected INCR_UTILITY after free")),1 : REALLY_INCR_UTILITY(ref))
02331 #   define DECR_UTILITY(ref) ((((ref)->refcount)==0x55555555) ? (HE_ERROR(0, 0, "detected DECR_UTILITY after free")),1 : REALLY_DECR_UTILITY(ref))
02332 #   define INIT_UTILITY(ref) ((ref)->refcount = 1)
02333 #else
02334 #   define INCR_UTILITY(ref) REALLY_INCR_UTILITY(ref)
02335 #   define DECR_UTILITY(ref) REALLY_DECR_UTILITY(ref)
02336 #   define INIT_UTILITY(ref) ((ref)->refcount = 1)
02337 #endif
02338 
02339 
02340 
02341 
02342 #define OPTIONS_HASH(index)     (&OUR(option_hash_tables[index]))
02343 
02344 /* the following would normally be in database.h, but put here
02345  * for the drivers.
02346  */
02347 /* MUST MATCH TABLE IN Show_Text_Font! */
02348 typedef int     HT_Generic_Font_Name;
02349 typedef char    HT_Font_Transform,
02350                 HT_Font_Size_Units;
02351 
02352 #define GFN_NONE                (HT_Generic_Font_Name)0 /* for use in drivers */
02353 #define GFN_SPECIFIED           (HT_Generic_Font_Name)1
02354 #define GFN_SYSTEM_DEFAULT      (HT_Generic_Font_Name)2
02355 #define GFN_SANS_SERIF          (HT_Generic_Font_Name)3
02356 #define GFN_TYPEWRITER          (HT_Generic_Font_Name)4
02357 #define GFN_ROMAN               (HT_Generic_Font_Name)5
02358 #define GFN_STROKED             (HT_Generic_Font_Name)6
02359 #define GFN_LAST_GFN            GFN_STROKED
02360 
02361 
02362 #define Encoding_INVALID        (HT_Text_Encoding)0
02363 
02364 #define Encoding_ISO_Latin_One  (HT_Text_Encoding)1
02365 #define Encoding_ISO_Latin      (HT_Text_Encoding)2
02366 #define Encoding_JEC            (HT_Text_Encoding)3     /* Shift-JIS */
02367 #define Encoding_EUC            (HT_Text_Encoding)4
02368 #define Encoding_Raw_16         (HT_Text_Encoding)5
02369 #define Encoding_Unicode        (HT_Text_Encoding)6
02370 #define Encoding_ISO_10646      (HT_Text_Encoding)7
02371 
02372 #define MAX_ENCODING            (HT_Text_Encoding)7
02373 
02374 #define Encoding_Mapping_NONE   (int)0
02375 #define Encoding_Mapping_DIRECT (int)1
02376 #define Encoding_Mapping_MAPPED (int)2
02377 
02378 
02379 
02380 struct HT_Intersection {
02381     struct {
02382         HT_Point const *        start;
02383         HT_Point const *        end;
02384         int                     start_index;
02385         int                     end_index;
02386         float                   fraction;
02387     }                   lines[2];
02388 };
02389 
02390 
02391 
02392 #ifndef FAMOTIK
02393 #   define  Encoding_DEFAULT    Encoding_ISO_Latin_One
02394 #else
02395 #   define  Encoding_DEFAULT    Encoding_JEC
02396 #endif
02397 
02398 #ifdef CADDS5
02399 #  define DISABLE_MUTEX
02400 #  ifdef __sparc
02401 #   undef HK_PLATFORM
02402 #   ifdef SOLARIS_SYSTEM
02403 #     define HK_PLATFORM  "Solaris 2.6 (SunOS 5.6, XGL 3.0.1)"
02404 #   else
02405 #     define HK_PLATFORM  "SunOS 4.1.3 (XGL 2.0-17)"
02406 #   endif
02407 #  endif
02408 #endif
02409 
02410 
02411 #define CODE_DISABLED(part) do {                                        \
02412             if (!BIT (OUR(warnings_given), Warn_Once_USE_DISABLED)) {   \
02413                 HE_ERROR2 (0, 0, EVERY (disabled_message), part);       \
02414                 OUR(warnings_given) |= Warn_Once_USE_DISABLED;          \
02415             }                                                           \
02416         } while (0)                                                    
02417 
02418 #define HOOPS_DEFINED
02419 #endif
Main Index
HOOPS/3dGS I.M. Interface

     << Back      Full Index      Forward >>