home *** CD-ROM | disk | FTP | other *** search
/ Learn 3D Graphics Programming on the PC / Learn_3D_Graphics_Programming_on_the_PC_Ferraro.iso / rwdos / rwmacros.h < prev    next >
C/C++ Source or Header  |  1995-02-15  |  2KB  |  88 lines

  1. /****************************************/
  2. /*                    */
  3. /*   RenderWare(TM) Graphics Library    */
  4. /*                    */
  5. /****************************************/
  6.  
  7. /*
  8.  * This file is a product of Criterion Software Ltd.
  9.  * 
  10.  * This file is provided as is with no warranties of any kind and is 
  11.  * provided without any obligiation on Criterion Software Ltd.
  12.  * or Canon Inc. to assist in its use or modifiation.
  13.  * 
  14.  * Criterion Software Ltd. and Canon Inc. will not, under any
  15.  * circumstances, be liable for any lost revenue or other damages
  16.  * arising from the use of this file.
  17.  *
  18.  * Copyright (c) 1991, 1992, 1993, 1994. Canon Inc.
  19.  * All Rights Reserved.
  20.  */
  21.  
  22. #ifndef _RW_MACROS_
  23. #define _RW_MACROS_
  24.  
  25. #ifdef RWFIXED
  26. #undef RWFIXED
  27. #define RWFIXED
  28. #endif
  29.  
  30. #ifdef RWFLOAT
  31. #undef RWFLOAT
  32. #define RWFLOAT
  33. #endif
  34.  
  35. #if (defined RWFLOAT) && (defined RWFIXED)
  36. #error "Inconsistent definitions of REAL type."
  37. #endif
  38.  
  39. #ifndef RWFIXED
  40.  
  41. #define RwReal float
  42.  
  43. #define CREAL(a) ((RwReal)(a))
  44. #define INT2REAL(a) ((RwReal)(a))
  45. #define REAL2INT(a) ((long)(a))
  46. #define REAL2FL(a) ((float)(a))
  47. #define FL2REAL(a) ((RwReal)(a))
  48.  
  49. #define RMul(a, b) ((a) * (b))
  50. #define RAdd(a, b) ((a) + (b))
  51. #define RDiv(a, b) ((a) / (b))
  52. #define RSub(a, b) ((a) - (b))
  53.  
  54. #define RSqrt(a) (sqrt(a))
  55.  
  56. #else /* RWFIXED */
  57.  
  58. #define RwReal long
  59.  
  60. #define CREAL(a) ((RwReal)((a) * 65536L))
  61. #define INT2REAL(a) ((RwReal)(((long)(a))<<16))
  62. #define REAL2INT(a) ((a)>>16)
  63. #define REAL2FL(a) (((float)(a))/65536.0f)
  64. #define FL2REAL(a) ((RwReal)((a)*65536.0f))
  65.  
  66. #define RMul(a, b) (_rwFixMul((a),(b)))
  67. #define RAdd(a, b) ((a) + (b))
  68. #define RDiv(a, b) (_rwFixDiv((a),(b)))
  69. #define RSub(a, b) ((a) - (b))
  70.  
  71. extern RwReal _rwFixMul ARGS((RwReal a, RwReal b));
  72. extern RwReal _rwFixDiv ARGS((RwReal a, RwReal b));
  73.  
  74. #define RSqrt(a) (_rwlsqrt(a))
  75. extern RwReal _rwlsqrt ARGS((RwReal a));
  76.  
  77. #endif
  78.  
  79. #if (!defined FALSE) && (!defined TRUE)
  80. #define FALSE 0
  81. #define TRUE !FALSE
  82. #endif
  83.  
  84. #define RAbs(a) (((a)<CREAL(0.0))?-(a):(a))
  85. /* Provided for backwards compatibility */
  86. #define Rabs(a) (((a)<CREAL(0.0))?-(a):(a))
  87. #endif /* _RW_MACROS_ */
  88.