2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
r_local.h
|
|
|
|
|
|
|
|
private refresh defs
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _R_LOCAL_H
|
|
|
|
#define _R_LOCAL_H
|
|
|
|
|
2012-05-11 12:22:10 +00:00
|
|
|
#include "QF/iqm.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2011-12-23 03:19:50 +00:00
|
|
|
#include "QF/render.h"
|
2012-05-11 12:22:10 +00:00
|
|
|
#include "QF/vid.h"
|
2021-03-09 14:52:40 +00:00
|
|
|
#include "QF/simd/mat4f.h"
|
|
|
|
#include "QF/simd/vec4f.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "r_shared.h"
|
|
|
|
|
|
|
|
#define ALIAS_BASE_SIZE_RATIO (1.0 / 11.0)
|
|
|
|
// normalizing factor so player model works out to about
|
|
|
|
// 1 pixel per triangle
|
|
|
|
|
|
|
|
#define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
|
|
|
|
// if bbox is trivially rejected
|
|
|
|
|
2001-05-14 01:22:58 +00:00
|
|
|
// viewmodel lighting =======================================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2022-03-17 06:04:30 +00:00
|
|
|
int ambientlight;
|
|
|
|
int shadelight;
|
|
|
|
vec3_t lightvec;
|
2001-02-19 21:15:25 +00:00
|
|
|
} alight_t;
|
|
|
|
|
2001-05-14 01:22:58 +00:00
|
|
|
// clipped bmodel edges =====================================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
typedef struct bedge_s
|
|
|
|
{
|
|
|
|
mvertex_t *v[2];
|
|
|
|
struct bedge_s *pnext;
|
|
|
|
} bedge_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float fv[3]; // viewspace x, y
|
|
|
|
} auxvert_t;
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
[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_speeds;
|
|
|
|
extern int r_timegraph;
|
|
|
|
extern int r_graphheight;
|
|
|
|
extern int r_clearcolor;
|
|
|
|
extern int r_waterwarp;
|
|
|
|
extern int r_drawentities;
|
|
|
|
extern int r_aliasstats;
|
|
|
|
extern int r_dspeeds;
|
|
|
|
extern int r_drawflat;
|
|
|
|
extern int r_ambient;
|
|
|
|
extern int r_reportsurfout;
|
|
|
|
extern int r_maxsurfs;
|
|
|
|
extern int r_numsurfs;
|
|
|
|
extern int r_reportedgeout;
|
|
|
|
extern int r_maxedges;
|
|
|
|
extern int r_numedges;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-04-25 12:51:04 +00:00
|
|
|
extern float cl_wateralpha;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#define XCENTERING (1.0 / 2.0)
|
|
|
|
#define YCENTERING (1.0 / 2.0)
|
|
|
|
|
|
|
|
#define CLIP_EPSILON 0.001
|
|
|
|
|
|
|
|
#define BACKFACE_EPSILON 0.01
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
#define DIST_NOT_SET 98765
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
2021-04-02 13:17:32 +00:00
|
|
|
typedef struct clipplane_s {
|
2001-02-19 21:15:25 +00:00
|
|
|
vec3_t normal;
|
|
|
|
float dist;
|
|
|
|
struct clipplane_s *next;
|
|
|
|
byte leftedge;
|
|
|
|
byte rightedge;
|
|
|
|
byte reserved[2];
|
|
|
|
} clipplane_t;
|
|
|
|
|
|
|
|
extern clipplane_t view_clipplanes[4];
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
void R_RenderWorld (void);
|
2022-03-17 08:50:38 +00:00
|
|
|
struct entqueue_s;
|
|
|
|
void R_DrawEntitiesOnList (struct entqueue_s *queue);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
2011-11-14 02:18:22 +00:00
|
|
|
extern plane_t screenedge[4];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-30 14:50:12 +00:00
|
|
|
extern vec4f_t r_entorigin;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern int r_visframecount;
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
extern int vstartscan;
|
|
|
|
|
|
|
|
|
|
|
|
void R_ClearPolyList (void);
|
|
|
|
void R_DrawPolyList (void);
|
|
|
|
|
2011-12-23 03:19:50 +00:00
|
|
|
// Surface cache related ==========
|
|
|
|
extern qboolean r_cache_thrash; // set if thrashing the surface cache
|
2001-05-14 01:22:58 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// current entity info
|
|
|
|
extern qboolean insubmodel;
|
|
|
|
extern vec3_t r_worldmodelorg;
|
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
extern mat4f_t glsl_projection;
|
|
|
|
extern mat4f_t glsl_view;
|
2011-12-31 05:38:03 +00:00
|
|
|
|
2022-03-19 01:06:38 +00:00
|
|
|
union refframe_s;
|
2022-03-19 03:33:12 +00:00
|
|
|
void R_SetFrustum (plane_t *frustum, const union refframe_s *frame,
|
|
|
|
float fov_x, float fov_y);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-29 05:40:48 +00:00
|
|
|
struct entity_s;
|
|
|
|
|
2011-12-30 12:11:59 +00:00
|
|
|
void R_SpriteBegin (void);
|
|
|
|
void R_SpriteEnd (void);
|
2022-03-29 05:40:48 +00:00
|
|
|
void R_DrawSprite (struct entity_s *ent);
|
|
|
|
void R_RenderFace (struct entity_s *ent, msurface_t *fa, int clipflags);
|
|
|
|
void R_RenderPoly (struct entity_s *ent, msurface_t *fa, int clipflags);
|
|
|
|
void R_RenderBmodelFace (struct entity_s *ent, bedge_t *pedges, msurface_t *psurf);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_TransformFrustum (void);
|
|
|
|
void R_SetSkyFrame (void);
|
2001-11-21 19:13:53 +00:00
|
|
|
void R_DrawSurfaceBlock (void);
|
2022-03-29 05:40:48 +00:00
|
|
|
texture_t *R_TextureAnimation (const struct entity_s *entity, msurface_t *surf) __attribute__((pure));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void R_GenSkyTile (void *pdest);
|
2001-11-21 19:13:53 +00:00
|
|
|
void R_SurfPatch (void);
|
2022-03-29 05:40:48 +00:00
|
|
|
void R_DrawSubmodelPolygons (struct entity_s *ent, model_t *pmodel, int clipflags, struct mnode_s *topnode);
|
|
|
|
void R_DrawSolidClippedSubmodelPolygons (struct entity_s *ent, model_t *pmodel, struct mnode_s *topnode);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void R_AddPolygonEdges (emitpoint_t *pverts, int numverts, int miplevel);
|
|
|
|
surf_t *R_GetSurf (void);
|
2012-05-18 14:31:14 +00:00
|
|
|
void R_AliasClipAndProjectFinalVert (finalvert_t *fv, auxvert_t *av);
|
2022-03-29 05:40:48 +00:00
|
|
|
void R_AliasDrawModel (struct entity_s *ent, alight_t *plighting);
|
|
|
|
void R_IQMDrawModel (struct entity_s *ent, alight_t *plighting);
|
|
|
|
struct animation_s;
|
|
|
|
maliasskindesc_t *R_AliasGetSkindesc (struct animation_s *animation, int skinnum, aliashdr_t *hdr);
|
|
|
|
maliasframedesc_t *R_AliasGetFramedesc (struct animation_s *animation, aliashdr_t *hdr);
|
|
|
|
float R_AliasGetLerpedFrames (struct animation_s *animation, aliashdr_t *hdr);
|
|
|
|
float R_IQMGetLerpedFrames (struct entity_s *ent, iqm_t *hdr);
|
2012-05-16 08:44:18 +00:00
|
|
|
iqmframe_t *R_IQMBlendFrames (const iqm_t *iqm, int frame1, int frame2,
|
2012-05-17 06:57:07 +00:00
|
|
|
float blend, int extra);
|
2012-05-18 15:34:15 +00:00
|
|
|
iqmframe_t *R_IQMBlendPalette (const iqm_t *iqm, int frame1, int frame2,
|
|
|
|
float blend, int extra,
|
|
|
|
iqmblend_t *blend_palette, int palette_size);
|
2022-03-29 05:40:48 +00:00
|
|
|
float R_EntityBlend (struct animation_s *animation, int pose, float interval);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_BeginEdgeFrame (void);
|
|
|
|
void R_ScanEdges (void);
|
|
|
|
void D_DrawSurfaces (void);
|
|
|
|
void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist);
|
|
|
|
void R_StepActiveU (edge_t *pedge);
|
|
|
|
void R_RemoveEdges (edge_t *pedge);
|
2011-12-17 10:14:14 +00:00
|
|
|
void R_AddTexture (texture_t *tex);
|
2021-01-19 16:25:54 +00:00
|
|
|
struct vulkan_ctx_s;
|
2011-12-17 10:14:14 +00:00
|
|
|
void R_ClearTextures (void);
|
2021-02-01 10:31:11 +00:00
|
|
|
void R_InitSurfaceChains (mod_brush_t *brush);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-29 04:08:58 +00:00
|
|
|
extern const byte *r_colormap;
|
|
|
|
void R_SetColormap (const byte *cmap);
|
2001-02-19 21:15:25 +00:00
|
|
|
extern void R_Surf8Start (void);
|
|
|
|
extern void R_Surf8End (void);
|
|
|
|
extern void R_EdgeCodeStart (void);
|
|
|
|
extern void R_EdgeCodeEnd (void);
|
|
|
|
|
2022-03-11 07:39:08 +00:00
|
|
|
struct transform_s;
|
|
|
|
extern void R_RotateBmodel (struct transform_s *transform);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern int c_faceclip;
|
|
|
|
extern int r_polycount;
|
|
|
|
|
|
|
|
extern int *pfrustum_indexes[4];
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in asm_draw.h too !!!
|
|
|
|
#define NEAR_CLIP 0.01
|
|
|
|
|
|
|
|
extern fixed16_t sadjust, tadjust;
|
|
|
|
extern fixed16_t bbextents, bbextentt;
|
|
|
|
|
|
|
|
#define MAXBVERTINDEXES 1000 // new clipped vertices when clipping bmodels
|
|
|
|
// to the world BSP
|
|
|
|
extern mvertex_t *r_ptverts, *r_ptvertsmax;
|
|
|
|
|
|
|
|
extern vec3_t sbaseaxis[3], tbaseaxis[3];
|
|
|
|
|
|
|
|
extern int r_currentkey;
|
|
|
|
extern int r_currentbkey;
|
|
|
|
|
|
|
|
typedef struct btofpoly_s {
|
|
|
|
int clipflags;
|
|
|
|
msurface_t *psurf;
|
|
|
|
} btofpoly_t;
|
|
|
|
|
|
|
|
#define MAX_BTOFPOLYS 5000 // FIXME: tune this
|
|
|
|
|
|
|
|
extern int numbtofpolys;
|
|
|
|
|
|
|
|
void R_InitTurb (void);
|
2022-03-29 05:40:48 +00:00
|
|
|
void R_ZDrawSubmodelPolys (struct entity_s *ent, model_t *clmodel);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 01:22:58 +00:00
|
|
|
// Alias models ===========================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#define ALIAS_Z_CLIP_PLANE 5
|
|
|
|
|
|
|
|
extern int numverts;
|
|
|
|
extern int numtriangles;
|
|
|
|
extern float leftclip, topclip, rightclip, bottomclip;
|
|
|
|
extern int r_acliptype;
|
|
|
|
extern finalvert_t *pfinalverts;
|
|
|
|
extern auxvert_t *pauxverts;
|
2022-03-09 11:19:14 +00:00
|
|
|
extern float ziscale;
|
2012-05-18 14:31:14 +00:00
|
|
|
extern float aliastransform[3][4];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-29 05:40:48 +00:00
|
|
|
qboolean R_AliasCheckBBox (struct entity_s *ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 01:22:58 +00:00
|
|
|
// turbulence stuff =======================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#define AMP 8*0x10000
|
|
|
|
#define AMP2 3
|
|
|
|
#define SPEED 20
|
|
|
|
|
2001-05-14 01:22:58 +00:00
|
|
|
// particle stuff =========================================
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-17 08:50:38 +00:00
|
|
|
struct psystem_s;
|
|
|
|
void R_DrawParticles (struct psystem_s *psystem);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_InitParticles (void);
|
2005-01-02 14:23:20 +00:00
|
|
|
void R_ClearParticles (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_ReadPointFile_f (void);
|
2003-03-20 19:58:18 +00:00
|
|
|
void R_InitSprites (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_SurfacePatch (void);
|
|
|
|
|
2003-08-27 22:20:03 +00:00
|
|
|
// renderer stuff again ===================================
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
extern int r_amodels_drawn;
|
|
|
|
extern edge_t *auxedges;
|
|
|
|
extern int r_numallocatededges;
|
|
|
|
extern edge_t *r_edges, *edge_p, *edge_max;
|
|
|
|
|
|
|
|
extern edge_t *newedges[MAXHEIGHT];
|
|
|
|
extern edge_t *removeedges[MAXHEIGHT];
|
|
|
|
|
|
|
|
extern int r_bmodelactive;
|
|
|
|
extern vrect_t *pconupdate;
|
|
|
|
|
|
|
|
extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
|
|
|
|
extern float r_aliastransition, r_resfudge;
|
|
|
|
|
|
|
|
extern int r_outofsurfaces;
|
|
|
|
extern int r_outofedges;
|
|
|
|
|
|
|
|
extern mvertex_t *r_pcurrentvertbase;
|
|
|
|
extern int r_maxvalidedgeoffset;
|
|
|
|
|
|
|
|
void R_AliasClipTriangle (mtriangle_t *ptri);
|
|
|
|
|
2022-03-15 06:42:43 +00:00
|
|
|
extern double r_time1;
|
2001-02-19 21:15:25 +00:00
|
|
|
extern int r_frustum_indexes[4*6];
|
2012-02-18 05:34:14 +00:00
|
|
|
extern int r_maxsurfsseen, r_maxedgesseen;
|
2001-02-19 21:15:25 +00:00
|
|
|
extern qboolean r_dowarpold, r_viewchanged;
|
|
|
|
|
|
|
|
extern int r_clipflags;
|
|
|
|
extern int r_dlightframecount;
|
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
extern struct entqueue_s *r_ent_queue;
|
2001-05-20 05:42:52 +00:00
|
|
|
struct dlight_s;
|
2001-05-20 02:39:56 +00:00
|
|
|
|
2012-02-17 09:33:07 +00:00
|
|
|
extern vec3_t lightspot;
|
|
|
|
|
2010-12-03 04:28:58 +00:00
|
|
|
void R_StoreEfrags (const efrag_t *ppefrag);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_TimeRefresh_f (void);
|
|
|
|
void R_PrintAliasStats (void);
|
|
|
|
void R_PrintTimes (void);
|
|
|
|
void R_AnimateLight (void);
|
2022-03-30 14:50:12 +00:00
|
|
|
int R_LightPoint (mod_brush_t *brush, vec4f_t p);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_SetupFrame (void);
|
|
|
|
void R_cshift_f (void);
|
|
|
|
void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1);
|
|
|
|
void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip);
|
2021-02-01 10:31:11 +00:00
|
|
|
void R_RecursiveMarkLights (mod_brush_t *brush, const vec3_t lightorigin,
|
|
|
|
struct dlight_s *light, int bit, mnode_t *node);
|
2002-01-03 05:29:38 +00:00
|
|
|
void R_MarkLights (const vec3_t lightorigin, struct dlight_s *light, int bit,
|
|
|
|
model_t *model);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-04-15 21:11:41 +00:00
|
|
|
void R_LoadSkys (const char *);
|
2021-01-19 16:25:54 +00:00
|
|
|
//void Vulkan_R_LoadSkys (const char *, struct vulkan_ctx_s *ctx);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-07 15:09:20 +00:00
|
|
|
void R_LowFPPrecision (void);
|
|
|
|
void R_HighFPPrecision (void);
|
|
|
|
void R_SetFPCW (void);
|
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av);
|
|
|
|
void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1,
|
|
|
|
finalvert_t *out);
|
|
|
|
void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1,
|
|
|
|
finalvert_t *out);
|
|
|
|
void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
|
|
|
|
finalvert_t *out);
|
|
|
|
void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out);
|
|
|
|
|
|
|
|
void R_AliasTransformVector (vec3_t in, vec3_t out);
|
2012-05-17 12:33:22 +00:00
|
|
|
void R_AliasTransformFinalVert (finalvert_t *fv, trivertx_t *pverts,
|
|
|
|
stvert_t *pstverts);
|
2002-11-05 19:12:51 +00:00
|
|
|
void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts);
|
|
|
|
|
|
|
|
void R_GenerateSpans (void);
|
|
|
|
|
|
|
|
void R_InitVars (void);
|
|
|
|
|
|
|
|
void R_LoadSky_f (void);
|
|
|
|
|
2011-12-26 12:43:15 +00:00
|
|
|
extern byte crosshair_data[];
|
|
|
|
#define CROSSHAIR_WIDTH 8
|
|
|
|
#define CROSSHAIR_HEIGHT 8
|
|
|
|
#define CROSSHAIR_TILEX 2
|
|
|
|
#define CROSSHAIR_TILEY 2
|
|
|
|
#define CROSSHAIR_COUNT (CROSSHAIR_TILEX * CROSSHAIR_TILEY)
|
|
|
|
|
2021-01-08 05:37:52 +00:00
|
|
|
//NOTE: This is packed 8x8 bitmap data, one byte per scanline, 8 scanlines
|
|
|
|
////per character. Also, it is NOT the quake font, but the IBM charset.
|
|
|
|
extern byte font8x8_data[];
|
|
|
|
|
2011-12-26 12:43:15 +00:00
|
|
|
struct qpic_s *Draw_CrosshairPic (void);
|
2021-01-08 05:37:52 +00:00
|
|
|
struct qpic_s *Draw_Font8x8Pic (void);
|
2011-12-26 12:43:15 +00:00
|
|
|
|
2012-01-21 10:13:01 +00:00
|
|
|
struct tex_s *R_DotParticleTexture (void);
|
|
|
|
struct tex_s *R_SparkParticleTexture (void);
|
|
|
|
struct tex_s *R_SmokeParticleTexture (void);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif // _R_LOCAL_H
|