render.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. // refresh.h -- public interface to refresh functions
  16. #define MAXCLIPPLANES 11
  17. #define TOP_RANGE 16 // soldier uniform colors
  18. #define BOTTOM_RANGE 96
  19. //=============================================================================
  20. typedef struct efrag_s
  21. {
  22. struct mleaf_s *leaf;
  23. struct efrag_s *leafnext;
  24. struct entity_s *entity;
  25. struct efrag_s *entnext;
  26. } efrag_t;
  27. typedef struct entity_s
  28. {
  29. qboolean forcelink; // model changed
  30. int update_type;
  31. entity_state_t baseline; // to fill in defaults in updates
  32. double msgtime; // time of last update
  33. vec3_t msg_origins[2]; // last two updates (0 is newest)
  34. vec3_t origin;
  35. vec3_t msg_angles[2]; // last two updates (0 is newest)
  36. vec3_t angles;
  37. struct model_s *model; // NULL = no model
  38. struct efrag_s *efrag; // linked list of efrags
  39. int frame;
  40. float syncbase; // for client-side animations
  41. byte *colormap;
  42. int effects; // light, particals, etc
  43. int skinnum; // for Alias models
  44. int visframe; // last frame this entity was
  45. // found in an active leaf
  46. int dlightframe; // dynamic lighting
  47. int dlightbits;
  48. // FIXME: could turn these into a union
  49. int trivial_accept;
  50. struct mnode_s *topnode; // for bmodels, first world node
  51. // that splits bmodel, or NULL if
  52. // not split
  53. } entity_t;
  54. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  55. typedef struct
  56. {
  57. vrect_t vrect; // subwindow in video for refresh
  58. // FIXME: not need vrect next field here?
  59. vrect_t aliasvrect; // scaled Alias version
  60. int vrectright, vrectbottom; // right & bottom screen coords
  61. int aliasvrectright, aliasvrectbottom; // scaled Alias versions
  62. float vrectrightedge; // rightmost right edge we care about,
  63. // for use in edge list
  64. float fvrectx, fvrecty; // for floating-point compares
  65. float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
  66. int vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20
  67. int vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
  68. float fvrectright_adj, fvrectbottom_adj;
  69. // right and bottom edges, for clamping
  70. float fvrectright; // rightmost edge, for Alias clamping
  71. float fvrectbottom; // bottommost edge, for Alias clamping
  72. float horizontalFieldOfView; // at Z = 1.0, this many X is visible
  73. // 2.0 = 90 degrees
  74. float xOrigin; // should probably allways be 0.5
  75. float yOrigin; // between be around 0.3 to 0.5
  76. vec3_t vieworg;
  77. vec3_t viewangles;
  78. float fov_x, fov_y;
  79. int ambientlight;
  80. } refdef_t;
  81. //
  82. // refresh
  83. //
  84. extern int reinit_surfcache;
  85. extern refdef_t r_refdef;
  86. extern vec3_t r_origin, vpn, vright, vup;
  87. extern struct texture_s *r_notexture_mip;
  88. void R_Init (void);
  89. void R_InitTextures (void);
  90. void R_InitEfrags (void);
  91. void R_RenderView (void); // must set r_refdef first
  92. void R_ViewChanged (vrect_t *pvrect, int lineadj, float aspect);
  93. // called whenever r_refdef or vid change
  94. void R_InitSky (struct texture_s *mt); // called at level load
  95. void R_AddEfrags (entity_t *ent);
  96. void R_RemoveEfrags (entity_t *ent);
  97. void R_NewMap (void);
  98. void R_ParseParticleEffect (void);
  99. void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
  100. void R_RocketTrail (vec3_t start, vec3_t end, int type);
  101. #ifdef QUAKE2
  102. void R_DarkFieldParticles (entity_t *ent);
  103. #endif
  104. void R_EntityParticles (entity_t *ent);
  105. void R_BlobExplosion (vec3_t org);
  106. void R_ParticleExplosion (vec3_t org);
  107. void R_ParticleExplosion2 (vec3_t org, int colorStart, int colorLength);
  108. void R_LavaSplash (vec3_t org);
  109. void R_TeleportSplash (vec3_t org);
  110. void R_PushDlights (void);
  111. //
  112. // surface cache related
  113. //
  114. extern int reinit_surfcache; // if 1, surface cache is currently empty and
  115. extern qboolean r_cache_thrash; // set if thrashing the surface cache
  116. int D_SurfaceCacheForRes (int width, int height);
  117. void D_FlushCaches (void);
  118. void D_DeleteSurfaceCache (void);
  119. void D_InitCaches (void *buffer, int size);
  120. void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);