render.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*=============================================================================
  2. Name : render.h
  3. Purpose : Initialise rendering system and provide a scene render entry point.
  4. Created 6/21/1997 by lmoloney
  5. Copyright Relic Entertainment, Inc. All rights reserved.
  6. =============================================================================*/
  7. #ifndef ___RENDER_H
  8. #define ___RENDER_H
  9. #include "types.h"
  10. #include "camera.h"
  11. #include "matrix.h"
  12. #include "color.h"
  13. #include "spaceobj.h"
  14. /*=============================================================================
  15. Switches:
  16. =============================================================================*/
  17. #ifndef HW_Release
  18. #define RND_ERROR_CHECKING 1 //basic error checking
  19. #define RND_VERBOSE_LEVEL 1 //control verbose printing
  20. #define RND_FRAME_RATE 1 //display frame rate
  21. #define RND_CAMERA_OFFSET 1 //offset camera by a certain amount to avoid lighting problems
  22. #define RND_BACKGROUND_CHECK 1 //check if we should display background
  23. #define RND_BACKGROUND_STATIC 1 //attach background to camera so it doesn't move at all
  24. #define RND_POLY_STATS 1 //display polygon stats
  25. #define RND_XYZ 1 //display position of selected ship
  26. #define RND_SCALECAP_TWEAK 0 //allow adjusting (and printing) of the scaling cap crap
  27. #define RND_GL_STATE_DEBUG 1 //dump the GL state to a file
  28. #define RND_GL_STATE_WINDOW 1 //dump the GL state to debug window
  29. #define RND_PLUG_DISABLEABLE 1 //can disable the shameless plug
  30. #define RND_VISUALIZATION 1 //enable special visualization options
  31. #else //HW_Debug
  32. #define RND_ERROR_CHECKING 0 //no error ckecking in retail
  33. #define RND_VERBOSE_LEVEL 0 //don't print any verbose strings in retail
  34. #define RND_FRAME_RATE 0 //display frame rate
  35. #define RND_CAMERA_OFFSET 1 //offset camera by a certain amount to avoid lighting problems
  36. #define RND_BACKGROUND_CHECK 1 //check if we should display background
  37. #define RND_BACKGROUND_STATIC 1 //attach background to camera so it doesn't move at all
  38. #define RND_POLY_STATS 0 //display polygon stats
  39. #define RND_XYZ 0 //display position of selected ship
  40. #define RND_SCALECAP_TWEAK 0 //allow adjusting (and printing) of the scaling cap crap
  41. #define RND_GL_STATE_DEBUG 0 //dump the GL state to a file
  42. #define RND_GL_STATE_WINDOW 0 //dump the GL state to debug window
  43. #define RND_PLUG_DISABLEABLE 0 //can disable the shameless plug
  44. #define RND_VISUALIZATION 0 //enable special visualization options
  45. #endif //HW_Debug
  46. /*=============================================================================
  47. Definitions:
  48. =============================================================================*/
  49. #define RND_StackSize (1024 * 10)
  50. #define RND_StarColor colRGB(180, 180, 200)
  51. #define RND_Race1BulletColor colRGB(254, 189, 39)
  52. #define RND_Race2BulletColor colRGB(4, 251, 66)
  53. #define RND_CameraOffsetX 3.0f
  54. #define RTE_Modulate 0
  55. #define RTE_Replace 1
  56. #define RTE_Decal 2
  57. #define RTE_Blend 3
  58. //scale cap debug stuff
  59. #define RND_CapScaleCapKey NUMPAD4
  60. #define RND_CapScaleCapKeyDec NUMPAD2
  61. #define RND_CapScaleCapKeyInc NUMPAD3
  62. #define rndCapScaleCapSlopeDelta 0.000001f
  63. /*=============================================================================
  64. Type definitions:
  65. =============================================================================*/
  66. //structure for info passed to the rndInit() functions
  67. typedef struct
  68. {
  69. sdword width;
  70. sdword height;
  71. void *hWnd; // don't want to include windows.h just for this!
  72. }
  73. rndinitdata;
  74. //user-defined render callback functions
  75. typedef void (*rendercallback)(void);
  76. typedef void (*renderfunction)(Camera *camera);
  77. /*=============================================================================
  78. Data:
  79. =============================================================================*/
  80. extern rendercallback rndPreObjectCallback, rndPostObjectCallback;
  81. extern udword rndFrameCount;
  82. extern real32 rndAspectRatio; //aspect ratio of rendering context
  83. extern bool8 rndFogOn;
  84. extern hmatrix rndCameraMatrix;
  85. extern hmatrix rndProjectionMatrix;
  86. extern sdword rndNormalization;
  87. extern bool rndTakeScreenshot;
  88. extern sdword rndLightingEnabled;
  89. extern sdword rndScissorEnabled;
  90. #if RND_POLY_STATS
  91. sdword rndDisplayPolyStats;
  92. sdword rndNumberPolys;
  93. sdword rndNumberTextured;
  94. sdword rndNumberSmoothed;
  95. sdword rndNumberDots;
  96. sdword rndNumberLines;
  97. #endif
  98. #if RND_PLUG_DISABLEABLE
  99. extern bool8 rndShamelessPlugEnabled;
  100. #endif
  101. extern renderfunction rndMainViewRender;
  102. /*=============================================================================
  103. Functions:
  104. =============================================================================*/
  105. //startup/shutdown the rendering module.
  106. sdword rndInit(rndinitdata *initData);
  107. sdword rndSmallInit(rndinitdata* initData, bool GL);
  108. void rndClose(void);
  109. //render a mission sphere using a specific camera. Or don't render; it's your call.
  110. void rndMainViewRenderFunction(Camera *camera); //normal rendering mode
  111. void rndMainViewRenderNothingFunction(Camera *camera); //don't do anything; just return
  112. void rndMainViewAllButRenderFunction(Camera *camera); //compute selection info but don't render
  113. void rndBackgroundRender(real32 radius, Camera *camera, bool bDrawStars);
  114. //main render task
  115. void rndRenderTask(void);
  116. //enable certain renderer options
  117. void rndHintInc(void);
  118. void rndBackFaceCullEnable(sdword bEnable);
  119. sdword rndLightingEnable(sdword bEnable);
  120. sdword rndTextureEnable(sdword bEnable);
  121. void rndBillboardEnable(vector *centre);
  122. void rndBillboardDisable(void);
  123. sdword rndTextureEnvironment(sdword mode);
  124. sdword rndPerspectiveCorrection(sdword bEnable);
  125. sdword rndNormalizeEnable(sdword bEnable);
  126. sdword rndAdditiveBlends(sdword bAdditive);
  127. sdword rndMaterialfv(sdword face, sdword pname, real32* params);
  128. void rndSetClearColor(color c);
  129. real32 rndComputeOverlap(Ship* ship, real32 scalar);
  130. void rndShamelessPlug(void);
  131. void rndEnvironmentMap(vector* camera, vector* A, vector* B, vector* C,
  132. vector* U, vector* V, vector* W);
  133. void rndEnvironmentMapConvex(vector* camera, vector* A, vector* B, vector* C,
  134. real32 convex, vector* U, vector* V, vector* W);
  135. void rndSetScreenFill(sdword count, color c);
  136. void rndLoadShamelessPlug(bool on); //load / free shameless plug texture
  137. void rndShamelessPlug(void);
  138. void rndResetGLState(void);
  139. void rndClearToBlack(void);
  140. void rndAllClearToBlack(void);
  141. void rndClear(void);
  142. void rndFlush(void);
  143. //render utility functions
  144. void rndRenderAHomeworld(void* camera, void *world);
  145. bool rndShipVisible(SpaceObj* spaceobj, Camera* camera);
  146. bool rndShipVisibleUsingCoordSys(SpaceObj* spaceobj, Camera* camera);
  147. void rndDrawScissorBars(bool scissorEnabled);
  148. #if RND_GL_STATE_DEBUG
  149. extern bool rndGLStateSaving;
  150. void rndGLStateLogFunction(char *location);
  151. #define rndGLStateLog(s) if (rndGLStateSaving) rndGLStateLogFunction(s);
  152. #else
  153. #define rndGLStateLog(s)
  154. #endif
  155. #endif //___RENDER_H