r_shared.h 4.7 KB

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