render.h 4.5 KB

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