1 /* 2 r_shared.h 3 4 general refresh-related stuff shared between the refresh and the driver 5 6 Copyright (C) 1996-1997 Id Software, Inc. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License 10 as published by the Free Software Foundation; either version 2 11 of the License, or (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 17 See the GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to: 21 22 Free Software Foundation, Inc. 23 59 Temple Place - Suite 330 24 Boston, MA 02111-1307, USA 25 26 */ 27 28 // FIXME: clean up and move into d_iface.h 29 30 #ifndef _R_SHARED_H 31 #define _R_SHARED_H 32 33 #include "d_iface.h" 34 35 #define MAX_EFRAGS 640 36 37 #define MAXVERTS 16 // max points in a surface polygon 38 #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate 39 // polygon (while processing) 40 // !!! if this is changed, it must be changed in d_ifacea.h too !!! 41 #define MAXHEIGHT 4096 42 #define MAXWIDTH 4096 43 #define MAXDIMENSION ((MAXHEIGHT > MAXWIDTH) ? MAXHEIGHT : MAXWIDTH) 44 45 #define SIN_BUFFER_SIZE (MAXDIMENSION+CYCLE) 46 47 #define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to 48 // be farther away than anything in 49 // the scene 50 51 //=================================================================== 52 53 extern void R_DrawLine (polyvert_t *polyvert0, polyvert_t *polyvert1); 54 55 extern int cachewidth; 56 extern byte *cacheblock; 57 extern int screenwidth; 58 extern int r_init; 59 60 extern float pixelAspect; 61 62 extern int r_drawnpolycount; 63 64 extern struct cvar_s *r_clearcolor; 65 66 extern int sintable[SIN_BUFFER_SIZE]; 67 extern int intsintable[SIN_BUFFER_SIZE]; 68 69 extern byte color_white[4]; 70 extern byte color_black[4]; 71 72 extern vec3_t vup, base_vup; 73 extern vec3_t vpn, base_vpn; 74 extern vec3_t vright, base_vright; 75 extern struct entity_s *currententity; 76 77 #define NUMSTACKEDGES 2400 //2000 78 #define MINEDGES NUMSTACKEDGES 79 #define NUMSTACKSURFACES 1000 80 #define MINSURFACES NUMSTACKSURFACES 81 #define MAXSPANS 3000 82 83 // !!! if this is changed, it must be changed in asm_draw.h too !!! 84 typedef struct espan_s 85 { 86 int u, v, count; 87 struct espan_s *pnext; 88 } espan_t; 89 90 // FIXME: compress, make a union if that will help 91 // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte 92 typedef struct surf_s 93 { 94 struct surf_s *next; // active surface stack in r_edge.c 95 struct surf_s *prev; // used in r_edge.c for active surf stack 96 struct espan_s *spans; // pointer to linked list of spans to draw 97 int key; // sorting key (BSP order) 98 int last_u; // set during tracing 99 int spanstate; // 0 = not in span 100 // 1 = in span 101 // -1 = in inverted span (end before 102 // start) 103 int flags; // currentface flags 104 void *data; // associated data like msurface_t 105 struct entity_s *entity; 106 float nearzi; // nearest 1/z on surface, for mipmapping 107 qboolean insubmodel; 108 float d_ziorigin, d_zistepu, d_zistepv; 109 110 int pad[2]; // to 64 bytes 111 } surf_t; 112 113 extern surf_t *surfaces, *surface_p, *surf_max; 114 115 // surfaces are generated in back to front order by the bsp, so if a surf 116 // pointer is greater than another one, it should be drawn in front 117 // surfaces[1] is the background, and is used as the active surface stack. 118 // surfaces[0] is a dummy, because index 0 is used to indicate no surface 119 // attached to an edge_t 120 121 //=================================================================== 122 123 extern vec3_t sxformaxis[4]; // s axis transformed into viewspace 124 extern vec3_t txformaxis[4]; // t axis transformed into viewspac 125 126 extern vec3_t modelorg, base_modelorg; 127 128 extern float xcenter, ycenter; 129 extern float xscale, yscale; 130 extern float xscaleinv, yscaleinv; 131 extern float xscaleshrink, yscaleshrink; 132 133 extern int d_lightstylevalue[256]; // 8.8 frac of base light value 134 135 extern void TransformVector (const vec3_t in, vec3_t out); 136 extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv, 137 fixed8_t endvertu, fixed8_t endvertv); 138 139 extern int r_skymade; 140 extern void R_MakeSky (void); 141 142 extern int gl_solidskytexture; 143 extern int gl_alphaskytexture; 144 145 // flags in finalvert_t.flags 146 #define ALIAS_LEFT_CLIP 0x0001 147 #define ALIAS_TOP_CLIP 0x0002 148 #define ALIAS_RIGHT_CLIP 0x0004 149 #define ALIAS_BOTTOM_CLIP 0x0008 150 #define ALIAS_Z_CLIP 0x0010 151 // !!! if this is changed, it must be changed in d_ifacea.h too !!! 152 #define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h; 153 // must be kept in sync 154 #define ALIAS_XY_CLIP_MASK 0x000F 155 156 // !!! if this is changed, it must be changed in asm_draw.h too !!! 157 typedef struct edge_s 158 { 159 fixed16_t u; 160 fixed16_t u_step; 161 struct edge_s *prev, *next; 162 unsigned short surfs[2]; 163 struct edge_s *nextremove; 164 float nearzi; 165 medge_t *owner; 166 } edge_t; 167 168 #define NUMVERTEXNORMALS 162 169 extern float r_avertexnormals[NUMVERTEXNORMALS][3]; 170 extern vec3_t ambientcolor; 171 172 #endif // _R_SHARED_H 173