r_local.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /*
  2. Copyright (C) 1996-1997 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // r_local.h -- private refresh defs
  16. #ifndef GLQUAKE
  17. #include "r_shared.h"
  18. #define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
  19. // normalizing factor so player model works out to about
  20. // 1 pixel per triangle
  21. #define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
  22. // if bbox is trivially rejected
  23. //===========================================================================
  24. // viewmodel lighting
  25. typedef struct {
  26. int ambientlight;
  27. int shadelight;
  28. float *plightvec;
  29. } alight_t;
  30. //===========================================================================
  31. // clipped bmodel edges
  32. typedef struct bedge_s
  33. {
  34. mvertex_t *v[2];
  35. struct bedge_s *pnext;
  36. } bedge_t;
  37. typedef struct {
  38. float fv[3]; // viewspace x, y
  39. } auxvert_t;
  40. //===========================================================================
  41. extern cvar_t r_draworder;
  42. extern cvar_t r_speeds;
  43. extern cvar_t r_timegraph;
  44. extern cvar_t r_graphheight;
  45. extern cvar_t r_clearcolor;
  46. extern cvar_t r_waterwarp;
  47. extern cvar_t r_fullbright;
  48. extern cvar_t r_drawentities;
  49. extern cvar_t r_aliasstats;
  50. extern cvar_t r_dspeeds;
  51. extern cvar_t r_drawflat;
  52. extern cvar_t r_ambient;
  53. extern cvar_t r_reportsurfout;
  54. extern cvar_t r_maxsurfs;
  55. extern cvar_t r_numsurfs;
  56. extern cvar_t r_reportedgeout;
  57. extern cvar_t r_maxedges;
  58. extern cvar_t r_numedges;
  59. #define XCENTERING (1.0 / 2.0)
  60. #define YCENTERING (1.0 / 2.0)
  61. #define CLIP_EPSILON 0.001
  62. #define BACKFACE_EPSILON 0.01
  63. //===========================================================================
  64. #define DIST_NOT_SET 98765
  65. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  66. typedef struct clipplane_s
  67. {
  68. vec3_t normal;
  69. float dist;
  70. struct clipplane_s *next;
  71. byte leftedge;
  72. byte rightedge;
  73. byte reserved[2];
  74. } clipplane_t;
  75. extern clipplane_t view_clipplanes[4];
  76. //=============================================================================
  77. void R_RenderWorld (void);
  78. //=============================================================================
  79. extern mplane_t screenedge[4];
  80. extern vec3_t r_origin;
  81. extern vec3_t r_entorigin;
  82. extern float screenAspect;
  83. extern float verticalFieldOfView;
  84. extern float xOrigin, yOrigin;
  85. extern int r_visframecount;
  86. //=============================================================================
  87. extern int vstartscan;
  88. void R_ClearPolyList (void);
  89. void R_DrawPolyList (void);
  90. //
  91. // current entity info
  92. //
  93. extern qboolean insubmodel;
  94. extern vec3_t r_worldmodelorg;
  95. void R_DrawSprite (void);
  96. void R_RenderFace (msurface_t *fa, int clipflags);
  97. void R_RenderPoly (msurface_t *fa, int clipflags);
  98. void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf);
  99. void R_TransformPlane (mplane_t *p, float *normal, float *dist);
  100. void R_TransformFrustum (void);
  101. void R_SetSkyFrame (void);
  102. void R_DrawSurfaceBlock16 (void);
  103. void R_DrawSurfaceBlock8 (void);
  104. texture_t *R_TextureAnimation (texture_t *base);
  105. #if id386
  106. void R_DrawSurfaceBlock8_mip0 (void);
  107. void R_DrawSurfaceBlock8_mip1 (void);
  108. void R_DrawSurfaceBlock8_mip2 (void);
  109. void R_DrawSurfaceBlock8_mip3 (void);
  110. #endif
  111. void R_GenSkyTile (void *pdest);
  112. void R_GenSkyTile16 (void *pdest);
  113. void R_Surf8Patch (void);
  114. void R_Surf16Patch (void);
  115. void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags);
  116. void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel);
  117. void R_AddPolygonEdges (emitpoint_t *pverts, int numverts, int miplevel);
  118. surf_t *R_GetSurf (void);
  119. void R_AliasDrawModel (alight_t *plighting);
  120. void R_BeginEdgeFrame (void);
  121. void R_ScanEdges (void);
  122. void D_DrawSurfaces (void);
  123. void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist);
  124. void R_StepActiveU (edge_t *pedge);
  125. void R_RemoveEdges (edge_t *pedge);
  126. extern void R_Surf8Start (void);
  127. extern void R_Surf8End (void);
  128. extern void R_Surf16Start (void);
  129. extern void R_Surf16End (void);
  130. extern void R_EdgeCodeStart (void);
  131. extern void R_EdgeCodeEnd (void);
  132. extern void R_RotateBmodel (void);
  133. extern int c_faceclip;
  134. extern int r_polycount;
  135. extern int r_wholepolycount;
  136. extern model_t *cl_worldmodel;
  137. extern int *pfrustum_indexes[4];
  138. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  139. #define NEAR_CLIP 0.01
  140. extern int ubasestep, errorterm, erroradjustup, erroradjustdown;
  141. extern int vstartscan;
  142. extern fixed16_t sadjust, tadjust;
  143. extern fixed16_t bbextents, bbextentt;
  144. #define MAXBVERTINDEXES 1000 // new clipped vertices when clipping bmodels
  145. // to the world BSP
  146. extern mvertex_t *r_ptverts, *r_ptvertsmax;
  147. extern vec3_t sbaseaxis[3], tbaseaxis[3];
  148. extern float entity_rotation[3][3];
  149. extern int reinit_surfcache;
  150. extern int r_currentkey;
  151. extern int r_currentbkey;
  152. typedef struct btofpoly_s {
  153. int clipflags;
  154. msurface_t *psurf;
  155. } btofpoly_t;
  156. #define MAX_BTOFPOLYS 5000 // FIXME: tune this
  157. extern int numbtofpolys;
  158. extern btofpoly_t *pbtofpolys;
  159. void R_InitTurb (void);
  160. void R_ZDrawSubmodelPolys (model_t *clmodel);
  161. //=========================================================
  162. // Alias models
  163. //=========================================================
  164. #define MAXALIASVERTS 2000 // TODO: tune this
  165. #define ALIAS_Z_CLIP_PLANE 5
  166. extern int numverts;
  167. extern int a_skinwidth;
  168. extern mtriangle_t *ptriangles;
  169. extern int numtriangles;
  170. extern aliashdr_t *paliashdr;
  171. extern mdl_t *pmdl;
  172. extern float leftclip, topclip, rightclip, bottomclip;
  173. extern int r_acliptype;
  174. extern finalvert_t *pfinalverts;
  175. extern auxvert_t *pauxverts;
  176. qboolean R_AliasCheckBBox (void);
  177. //=========================================================
  178. // turbulence stuff
  179. #define AMP 8*0x10000
  180. #define AMP2 3
  181. #define SPEED 20
  182. //=========================================================
  183. // particle stuff
  184. void R_DrawParticles (void);
  185. void R_InitParticles (void);
  186. void R_ClearParticles (void);
  187. void R_ReadPointFile_f (void);
  188. void R_SurfacePatch (void);
  189. extern int r_amodels_drawn;
  190. extern edge_t *auxedges;
  191. extern int r_numallocatededges;
  192. extern edge_t *r_edges, *edge_p, *edge_max;
  193. extern edge_t *newedges[MAXHEIGHT];
  194. extern edge_t *removeedges[MAXHEIGHT];
  195. extern int screenwidth;
  196. // FIXME: make stack vars when debugging done
  197. extern edge_t edge_head;
  198. extern edge_t edge_tail;
  199. extern edge_t edge_aftertail;
  200. extern int r_bmodelactive;
  201. extern vrect_t *pconupdate;
  202. extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
  203. extern float r_aliastransition, r_resfudge;
  204. extern int r_outofsurfaces;
  205. extern int r_outofedges;
  206. extern mvertex_t *r_pcurrentvertbase;
  207. extern int r_maxvalidedgeoffset;
  208. void R_AliasClipTriangle (mtriangle_t *ptri);
  209. extern float r_time1;
  210. extern float dp_time1, dp_time2, db_time1, db_time2, rw_time1, rw_time2;
  211. extern float se_time1, se_time2, de_time1, de_time2, dv_time1, dv_time2;
  212. extern int r_frustum_indexes[4*6];
  213. extern int r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs;
  214. extern qboolean r_surfsonstack;
  215. extern cshift_t cshift_water;
  216. extern qboolean r_dowarpold, r_viewchanged;
  217. extern mleaf_t *r_viewleaf, *r_oldviewleaf;
  218. extern vec3_t r_emins, r_emaxs;
  219. extern mnode_t *r_pefragtopnode;
  220. extern int r_clipflags;
  221. extern int r_dlightframecount;
  222. extern qboolean r_fov_greater_than_90;
  223. void R_StoreEfrags (efrag_t **ppefrag);
  224. void R_TimeRefresh_f (void);
  225. void R_TimeGraph (void);
  226. void R_PrintAliasStats (void);
  227. void R_PrintTimes (void);
  228. void R_PrintDSpeeds (void);
  229. void R_AnimateLight (void);
  230. int R_LightPoint (vec3_t p);
  231. void R_SetupFrame (void);
  232. void R_cshift_f (void);
  233. void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1);
  234. void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip);
  235. void R_SplitEntityOnNode2 (mnode_t *node);
  236. void R_MarkLights (dlight_t *light, int bit, mnode_t *node);
  237. #endif //GLQUAKE