home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Homebrewer's Handbook / vr.iso / vr386 / vr_ctype.h < prev    next >
C/C++ Source or Header  |  1996-03-19  |  4KB  |  143 lines

  1. // redefineable VR-386 types
  2. // for API, also for compiler portability
  3. // Dave Stampe, 29/12/93
  4.  
  5.  
  6. /// THESE TYPES ARE FOR COMPILER PORTABILITY
  7. /*
  8.  This code is part of the VR-386 project, created by Dave Stampe.
  9.  VR-386 is a desendent of REND386, created by Dave Stampe and
  10.  Bernie Roehl.  Almost all the code has been rewritten by Dave
  11.  Stampre for VR-386.
  12.  
  13.  Copyright (c) 1994 by Dave Stampe:
  14.  May be freely used to write software for release into the public domain
  15.  or for educational use; all commercial endeavours MUST contact Dave Stampe
  16.  (dstampe@psych.toronto.edu) for permission to incorporate any part of
  17.  this software or source code into their products!  Usually there is no
  18.  charge for under 50-100 items for low-cost or shareware products, and terms
  19.  are reasonable.  Any royalties are used for development, so equipment is
  20.  often acceptable payment.
  21.  
  22.  ATTRIBUTION:  If you use any part of this source code or the libraries
  23.  in your projects, you must give attribution to VR-386 and Dave Stampe,
  24.  and any other authors in your documentation, source code, and at startup
  25.  of your program.  Let's keep the freeware ball rolling!
  26.  
  27.  DEVELOPMENT: VR-386 is a effort to develop the process started by
  28.  REND386, improving programmer access by rewriting the code and supplying
  29.  a standard API.  If you write improvements, add new functions rather
  30.  than rewriting current functions.  This will make it possible to
  31.  include you improved code in the next API release.  YOU can help advance
  32.  VR-386.  Comments on the API are welcome.
  33.  
  34.  CONTACT: dstampe@psych.toronto.edu
  35. */
  36.  
  37.  
  38. typedef unsigned char BYTE;   // types for compiler portability
  39. typedef unsigned int WORD;
  40. typedef signed char SBYTE;
  41. typedef signed int SWORD;
  42. typedef long DWORD;
  43.  
  44. typedef signed char BOOL;
  45. #define TRUE  1
  46. #define FALSE 0
  47.  
  48. typedef DWORD COORD;     // <32.0>  for position
  49. typedef DWORD ANGLE;     // <16.16> for angle
  50. typedef DWORD MATVAL;    // <3.29> for trig
  51. typedef DWORD SCALE;     // <16.16> for scaling
  52.  
  53.  
  54. //// THESE TYPES ARE ALSO IN 3DSTRUCT.H WHICH MAY BE INCLUDED FOR DEBUGGING
  55.  
  56. #ifndef SCRIDEF
  57. #define SCRIDEF 1
  58. struct Screeninfo {
  59.     WORD xmin, ymin, xmax, ymax, xcent, ycent, colors, pages, bw;
  60.     SCALE aspect;
  61.     char id[80];
  62.     };
  63. #endif
  64.  
  65. #ifndef MATRIXDEF
  66. typedef MATVAL MATRIX[4][3];  /* 3x3 rotate plus 3 translate para's */
  67. #define MATRIXDEF 1           /* rotate matrix is <3.29>, translate is <32.0> */
  68. #endif
  69.  
  70.  
  71. #ifndef VIEWDEF
  72. #define VIEWDEF 1
  73. typedef struct {
  74.     SCALE zoom;              /* <16.16> 1/tan(H FOV/2) 0.5 to 16     */
  75.  
  76.     DWORD left,right;        /* <25.0> clipping planes */
  77.     DWORD top, bottom;
  78.     DWORD hither, yon;       /* <25.0> near and far clipping planes   */
  79.     SCALE aspect;            /* <16.16> x:y fixup factor (magnify Y by...) */
  80.  
  81.     WORD flags;         /* 16 bits of flags */
  82.  
  83.     DWORD x_offset, y_offset;   /* amount to move screen center in pixels */
  84.     WORD  orientation;      /* used to mirror screen image */
  85. #define NOFLIP 0x0000      /* bits used in orientation field */
  86. #define XFLIP  0x0001
  87. #define YFLIP  0x0002
  88.  
  89.     MATRIX eye_xform;
  90.  
  91.     DWORD spare[17];   // PRIVATE view data caching
  92.     } VIEW;
  93. #endif
  94.  
  95. #ifndef POLYDEF
  96. #define POLYDEF 1
  97. typedef void POLY;
  98. #endif
  99.  
  100. #ifndef REPDEF
  101. #define REPDEF 1
  102. typedef void REP;
  103. #endif
  104.  
  105. #ifndef OBJDEF
  106. #define OBJDEF 1
  107. typedef WORD *OBJECT;    // for now (generic name for SEGMENT and OBJECT)
  108.             // this just accesses the flags field for type checks
  109. typedef void *VISOBJ;    // special case of OBJECT
  110. #endif
  111.  
  112. #ifndef OBJLDEF
  113. #define OBJLDEF 1
  114. typedef void *OBJLIST;
  115. #endif
  116.  
  117. #ifndef SEGDEF
  118. #define SEGDEF 1
  119. typedef void SEGMENT;
  120. #endif
  121.  
  122. #ifndef SPLDEF
  123. #define SPLDEF 1
  124. typedef void SPLIT;
  125. #endif
  126.  
  127. typedef unsigned SURFACE;
  128.  
  129. /// THESE ARE TYPE-CONVERSION MACROS
  130.  
  131. #define XFFP 536870912.0
  132.  
  133. #define float2coord(p)  ((COORD)p)
  134. #define coord2float(p)  ((float)p)
  135. #define float2scale(p)  ((SCALE)(p*65536.0))
  136. #define scale2float(p)  (p/65536.0)
  137. #define float2angle(p)  ((ANGLE)(p*65536.0))
  138. #define angle2float(p)  (p/65536.0)
  139. #define float2matval(p) ((MATVAL)(p*XFFP))
  140. #define matval2float(p) (p/XFFP)
  141.  
  142.  
  143.