2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 // r_shared.h: general refresh-related stuff shared between the refresh and the
24 // FIXME: clean up and move into d_iface.h
29 #define MAXVERTS 16 // max points in a surface polygon
30 #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
31 // polygon (while processing)
32 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
33 #define MAXHEIGHT 1024
35 #define MAXDIMENSION ((MAXHEIGHT > MAXWIDTH) ? MAXHEIGHT : MAXWIDTH)
37 #define SIN_BUFFER_SIZE (MAXDIMENSION+CYCLE)
39 #define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to
40 // be farther away than anything in
43 //===================================================================
45 extern void R_DrawLine (polyvert_t
*polyvert0
, polyvert_t
*polyvert1
);
47 extern int cachewidth
;
48 extern pixel_t
*cacheblock
;
49 extern int screenwidth
;
51 extern float pixelAspect
;
53 extern int r_drawnpolycount
;
55 extern cvar_t r_clearcolor
;
57 extern int sintable
[SIN_BUFFER_SIZE
];
58 extern int intsintable
[SIN_BUFFER_SIZE
];
60 extern vec3_t vup
, base_vup
;
61 extern vec3_t vpn
, base_vpn
;
62 extern vec3_t vright
, base_vright
;
63 extern entity_t
*currententity
;
65 #define NUMSTACKEDGES 2400
66 #define MINEDGES NUMSTACKEDGES
67 #define NUMSTACKSURFACES 800
68 #define MINSURFACES NUMSTACKSURFACES
71 // !!! if this is changed, it must be changed in asm_draw.h too !!!
72 typedef struct espan_s
75 struct espan_s
*pnext
;
78 // FIXME: compress, make a union if that will help
79 // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte
82 struct surf_s
*next
; // active surface stack in r_edge.c
83 struct surf_s
*prev
; // used in r_edge.c for active surf stack
84 struct espan_s
*spans
; // pointer to linked list of spans to draw
85 int key
; // sorting key (BSP order)
86 int last_u
; // set during tracing
87 int spanstate
; // 0 = not in span
89 // -1 = in inverted span (end before
91 int flags
; // currentface flags
92 void *data
; // associated data like msurface_t
94 float nearzi
; // nearest 1/z on surface, for mipmapping
96 float d_ziorigin
, d_zistepu
, d_zistepv
;
98 int pad
[2]; // to 64 bytes
101 extern surf_t
*surfaces
, *surface_p
, *surf_max
;
103 // surfaces are generated in back to front order by the bsp, so if a surf
104 // pointer is greater than another one, it should be drawn in front
105 // surfaces[1] is the background, and is used as the active surface stack.
106 // surfaces[0] is a dummy, because index 0 is used to indicate no surface
107 // attached to an edge_t
109 //===================================================================
111 extern vec3_t sxformaxis
[4]; // s axis transformed into viewspace
112 extern vec3_t txformaxis
[4]; // t axis transformed into viewspac
114 extern vec3_t modelorg
, base_modelorg
;
116 extern float xcenter
, ycenter
;
117 extern float xscale
, yscale
;
118 extern float xscaleinv
, yscaleinv
;
119 extern float xscaleshrink
, yscaleshrink
;
121 extern int d_lightstylevalue
[256]; // 8.8 frac of base light value
123 extern void TransformVector (vec3_t in
, vec3_t out
);
124 extern void SetUpForLineScan(fixed8_t startvertu
, fixed8_t startvertv
,
125 fixed8_t endvertu
, fixed8_t endvertv
);
127 extern int r_skymade
;
128 extern void R_MakeSky (void);
130 extern int ubasestep
, errorterm
, erroradjustup
, erroradjustdown
;
132 // flags in finalvert_t.flags
133 #define ALIAS_LEFT_CLIP 0x0001
134 #define ALIAS_TOP_CLIP 0x0002
135 #define ALIAS_RIGHT_CLIP 0x0004
136 #define ALIAS_BOTTOM_CLIP 0x0008
137 #define ALIAS_Z_CLIP 0x0010
138 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
139 #define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h;
140 // must be kept in sync
141 #define ALIAS_XY_CLIP_MASK 0x000F
143 // !!! if this is changed, it must be changed in asm_draw.h too !!!
144 typedef struct edge_s
148 struct edge_s
*prev
, *next
;
149 unsigned short surfs
[2];
150 struct edge_s
*nextremove
;
155 #endif // _R_SHARED_H_