2001-04-15 05:18:23 +00:00
|
|
|
/*
|
|
|
|
r_shared.h
|
|
|
|
|
|
|
|
general refresh-related stuff shared between the refresh and the driver
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// FIXME: clean up and move into d_iface.h
|
|
|
|
|
|
|
|
#ifndef _R_SHARED_H
|
|
|
|
#define _R_SHARED_H
|
|
|
|
|
|
|
|
#include "d_iface.h"
|
|
|
|
|
2001-05-20 01:58:59 +00:00
|
|
|
#define MAX_EFRAGS 640
|
|
|
|
|
2001-04-15 05:18:23 +00:00
|
|
|
#define MAXVERTS 16 // max points in a surface polygon
|
|
|
|
#define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
|
|
|
|
// polygon (while processing)
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
2009-12-20 05:34:41 +00:00
|
|
|
#define MAXHEIGHT 4096
|
|
|
|
#define MAXWIDTH 4096
|
2001-05-10 06:01:11 +00:00
|
|
|
#define MAXDIMENSION ((MAXHEIGHT > MAXWIDTH) ? MAXHEIGHT : MAXWIDTH)
|
|
|
|
|
|
|
|
#define SIN_BUFFER_SIZE (MAXDIMENSION+CYCLE)
|
2001-04-15 05:18:23 +00:00
|
|
|
|
|
|
|
#define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to
|
|
|
|
// be farther away than anything in
|
|
|
|
// the scene
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
|
|
|
extern void R_DrawLine (polyvert_t *polyvert0, polyvert_t *polyvert1);
|
|
|
|
|
|
|
|
extern int cachewidth;
|
2001-08-25 02:47:11 +00:00
|
|
|
extern byte *cacheblock;
|
2001-12-19 04:03:57 +00:00
|
|
|
extern int r_init;
|
2001-04-15 05:18:23 +00:00
|
|
|
|
2001-08-25 02:47:11 +00:00
|
|
|
extern float pixelAspect;
|
2001-04-15 05:18:23 +00:00
|
|
|
|
|
|
|
extern int r_drawnpolycount;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
extern int r_clearcolor;
|
2001-04-15 05:18:23 +00:00
|
|
|
|
2001-05-10 06:01:11 +00:00
|
|
|
extern int sintable[SIN_BUFFER_SIZE];
|
|
|
|
extern int intsintable[SIN_BUFFER_SIZE];
|
2001-04-15 05:18:23 +00:00
|
|
|
|
2001-08-30 18:24:19 +00:00
|
|
|
extern byte color_white[4];
|
|
|
|
extern byte color_black[4];
|
|
|
|
|
2001-04-15 05:18:23 +00:00
|
|
|
extern vec3_t vup, base_vup;
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
extern vec3_t vfwd, base_vfwd;
|
2001-04-15 05:18:23 +00:00
|
|
|
extern vec3_t vright, base_vright;
|
2022-03-14 02:56:10 +00:00
|
|
|
extern float r_viewmatrix[3][4];
|
2001-04-15 05:18:23 +00:00
|
|
|
|
2001-05-10 06:01:11 +00:00
|
|
|
#define NUMSTACKEDGES 2400 //2000
|
2001-04-15 05:18:23 +00:00
|
|
|
#define MINEDGES NUMSTACKEDGES
|
|
|
|
#define NUMSTACKSURFACES 1000
|
|
|
|
#define MINSURFACES NUMSTACKSURFACES
|
|
|
|
#define MAXSPANS 3000
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
2021-04-02 13:17:32 +00:00
|
|
|
typedef struct espan_s {
|
2001-04-15 05:18:23 +00:00
|
|
|
int u, v, count;
|
|
|
|
struct espan_s *pnext;
|
|
|
|
} espan_t;
|
|
|
|
|
|
|
|
// FIXME: compress, make a union if that will help
|
|
|
|
// insubmodel is only 1, flags is fewer than 32, spanstate could be a byte
|
2021-04-02 13:17:32 +00:00
|
|
|
typedef struct surf_s {
|
2001-04-15 05:18:23 +00:00
|
|
|
struct surf_s *next; // active surface stack in r_edge.c
|
|
|
|
struct surf_s *prev; // used in r_edge.c for active surf stack
|
|
|
|
struct espan_s *spans; // pointer to linked list of spans to draw
|
|
|
|
int key; // sorting key (BSP order)
|
|
|
|
int last_u; // set during tracing
|
|
|
|
int spanstate; // 0 = not in span
|
|
|
|
// 1 = in span
|
|
|
|
// -1 = in inverted span (end before
|
|
|
|
// start)
|
|
|
|
int flags; // currentface flags
|
|
|
|
void *data; // associated data like msurface_t
|
2022-10-25 10:36:09 +00:00
|
|
|
uint32_t render_id;
|
2001-04-15 05:18:23 +00:00
|
|
|
float nearzi; // nearest 1/z on surface, for mipmapping
|
|
|
|
qboolean insubmodel;
|
|
|
|
float d_ziorigin, d_zistepu, d_zistepv;
|
|
|
|
|
2022-03-06 23:44:53 +00:00
|
|
|
int pad[2]; // to 64 bytes (FIXME not for 64-bit)
|
2001-04-15 05:18:23 +00:00
|
|
|
} surf_t;
|
|
|
|
|
|
|
|
extern surf_t *surfaces, *surface_p, *surf_max;
|
|
|
|
|
|
|
|
// surfaces are generated in back to front order by the bsp, so if a surf
|
|
|
|
// pointer is greater than another one, it should be drawn in front
|
|
|
|
// surfaces[1] is the background, and is used as the active surface stack.
|
|
|
|
// surfaces[0] is a dummy, because index 0 is used to indicate no surface
|
|
|
|
// attached to an edge_t
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
|
|
|
extern vec3_t sxformaxis[4]; // s axis transformed into viewspace
|
|
|
|
extern vec3_t txformaxis[4]; // t axis transformed into viewspac
|
|
|
|
|
|
|
|
extern vec3_t modelorg, base_modelorg;
|
|
|
|
|
|
|
|
extern float xcenter, ycenter;
|
|
|
|
extern float xscale, yscale;
|
|
|
|
extern float xscaleinv, yscaleinv;
|
|
|
|
extern float xscaleshrink, yscaleshrink;
|
|
|
|
|
|
|
|
extern int d_lightstylevalue[256]; // 8.8 frac of base light value
|
|
|
|
|
2002-01-03 05:29:38 +00:00
|
|
|
extern void TransformVector (const vec3_t in, vec3_t out);
|
2001-04-15 05:18:23 +00:00
|
|
|
extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
|
|
|
|
fixed8_t endvertu, fixed8_t endvertv);
|
|
|
|
|
2012-02-18 05:34:14 +00:00
|
|
|
extern int r_skymade;
|
2001-04-15 05:18:23 +00:00
|
|
|
extern void R_MakeSky (void);
|
|
|
|
|
|
|
|
// flags in finalvert_t.flags
|
|
|
|
#define ALIAS_LEFT_CLIP 0x0001
|
|
|
|
#define ALIAS_TOP_CLIP 0x0002
|
|
|
|
#define ALIAS_RIGHT_CLIP 0x0004
|
|
|
|
#define ALIAS_BOTTOM_CLIP 0x0008
|
|
|
|
#define ALIAS_Z_CLIP 0x0010
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
|
|
|
#define ALIAS_ONSEAM 0x0020 // also defined in modelgen.h;
|
|
|
|
// must be kept in sync
|
|
|
|
#define ALIAS_XY_CLIP_MASK 0x000F
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
|
|
|
typedef struct edge_s
|
|
|
|
{
|
|
|
|
fixed16_t u;
|
|
|
|
fixed16_t u_step;
|
|
|
|
struct edge_s *prev, *next;
|
|
|
|
unsigned short surfs[2];
|
|
|
|
struct edge_s *nextremove;
|
|
|
|
float nearzi;
|
|
|
|
medge_t *owner;
|
|
|
|
} edge_t;
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
#define NUMVERTEXNORMALS 162
|
|
|
|
extern float r_avertexnormals[NUMVERTEXNORMALS][3];
|
2002-08-12 06:14:55 +00:00
|
|
|
extern vec3_t ambientcolor;
|
2001-10-28 04:23:37 +00:00
|
|
|
|
2022-10-25 10:36:09 +00:00
|
|
|
uint32_t SW_AddEntity (entity_t ent);
|
|
|
|
|
2001-04-15 05:18:23 +00:00
|
|
|
#endif // _R_SHARED_H
|