r_shared.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. #ifndef GLQUAKE
  16. // r_shared.h: general refresh-related stuff shared between the refresh and the
  17. // driver
  18. // FIXME: clean up and move into d_iface.h
  19. #ifndef _R_SHARED_H_
  20. #define _R_SHARED_H_
  21. #define MAXVERTS 16 // max points in a surface polygon
  22. #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
  23. // polygon (while processing)
  24. // !!! if this is changed, it must be changed in d_ifacea.h too !!!
  25. #define MAXHEIGHT 1024
  26. #define MAXWIDTH 1280
  27. #define MAXDIMENSION ((MAXHEIGHT > MAXWIDTH) ? MAXHEIGHT : MAXWIDTH)
  28. #define SIN_BUFFER_SIZE (MAXDIMENSION+CYCLE)
  29. #define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to
  30. // be farther away than anything in
  31. // the scene
  32. //===================================================================
  33. extern void R_DrawLine (polyvert_t *polyvert0, polyvert_t *polyvert1);
  34. extern int cachewidth;
  35. extern pixel_t *cacheblock;
  36. extern int screenwidth;
  37. extern float pixelAspect;
  38. extern int r_drawnpolycount;
  39. extern cvar_t r_clearcolor;
  40. extern int sintable[SIN_BUFFER_SIZE];
  41. extern int intsintable[SIN_BUFFER_SIZE];
  42. extern vec3_t vup, base_vup;
  43. extern vec3_t vpn, base_vpn;
  44. extern vec3_t vright, base_vright;
  45. extern entity_t *currententity;
  46. #define NUMSTACKEDGES 2400
  47. #define MINEDGES NUMSTACKEDGES
  48. #define NUMSTACKSURFACES 800
  49. #define MINSURFACES NUMSTACKSURFACES
  50. #define MAXSPANS 3000
  51. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  52. typedef struct espan_s
  53. {
  54. int u, v, count;
  55. struct espan_s *pnext;
  56. } espan_t;
  57. // FIXME: compress, make a union if that will help
  58. // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte
  59. typedef struct surf_s
  60. {
  61. struct surf_s *next; // active surface stack in r_edge.c
  62. struct surf_s *prev; // used in r_edge.c for active surf stack
  63. struct espan_s *spans; // pointer to linked list of spans to draw
  64. int key; // sorting key (BSP order)
  65. int last_u; // set during tracing
  66. int spanstate; // 0 = not in span
  67. // 1 = in span
  68. // -1 = in inverted span (end before
  69. // start)
  70. int flags; // currentface flags
  71. void *data; // associated data like msurface_t
  72. entity_t *entity;
  73. float nearzi; // nearest 1/z on surface, for mipmapping
  74. qboolean insubmodel;
  75. float d_ziorigin, d_zistepu, d_zistepv;
  76. int pad[2]; // to 64 bytes
  77. } surf_t;
  78. extern surf_t *surfaces, *surface_p, *surf_max;
  79. // surfaces are generated in back to front order by the bsp, so if a surf
  80. // pointer is greater than another one, it should be drawn in front
  81. // surfaces[1] is the background, and is used as the active surface stack.
  82. // surfaces[0] is a dummy, because index 0 is used to indicate no surface
  83. // attached to an edge_t
  84. //===================================================================
  85. extern vec3_t sxformaxis[4]; // s axis transformed into viewspace
  86. extern vec3_t txformaxis[4]; // t axis transformed into viewspac
  87. extern vec3_t modelorg, base_modelorg;
  88. extern float xcenter, ycenter;
  89. extern float xscale, yscale;
  90. extern float xscaleinv, yscaleinv;
  91. extern float xscaleshrink, yscaleshrink;
  92. extern int d_lightstylevalue[256]; // 8.8 frac of base light value
  93. extern void TransformVector (vec3_t in, vec3_t out);
  94. extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
  95. fixed8_t endvertu, fixed8_t endvertv);
  96. extern int r_skymade;
  97. extern void R_MakeSky (void);
  98. extern int ubasestep, errorterm, erroradjustup, erroradjustdown;
  99. // flags in finalvert_t.flags
  100. #define ALIAS_LEFT_CLIP 0x0001
  101. #define ALIAS_TOP_CLIP 0x0002
  102. #define ALIAS_RIGHT_CLIP 0x0004
  103. #define ALIAS_BOTTOM_CLIP 0x0008
  104. #define ALIAS_Z_CLIP 0x0010
  105. // !!! if this is changed, it must be changed in d_ifacea.h too !!!
  106. #define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h;
  107. // must be kept in sync
  108. #define ALIAS_XY_CLIP_MASK 0x000F
  109. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  110. typedef struct edge_s
  111. {
  112. fixed16_t u;
  113. fixed16_t u_step;
  114. struct edge_s *prev, *next;
  115. unsigned short surfs[2];
  116. struct edge_s *nextremove;
  117. float nearzi;
  118. medge_t *owner;
  119. } edge_t;
  120. #endif // _R_SHARED_H_
  121. #endif // GLQUAKE