Renderer merge continues. gl_rlight, gl_rmisc, gl_rmain, and gl_rsurf the current victims.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2001-05-13 00:28:50 +00:00
parent fc456ac040
commit 220f8a6e38
11 changed files with 445 additions and 546 deletions

View file

@ -272,6 +272,7 @@ extern cvar_t *m_yaw;
extern cvar_t *m_forward; extern cvar_t *m_forward;
extern cvar_t *m_side; extern cvar_t *m_side;
extern struct cvar_s *name;
#define MAX_TEMP_ENTITIES 64 // lightning bolts, etc #define MAX_TEMP_ENTITIES 64 // lightning bolts, etc
#define MAX_STATIC_ENTITIES 128 // torches, etc #define MAX_STATIC_ENTITIES 128 // torches, etc

View file

@ -123,7 +123,7 @@ nq_x11_DEPENDENCIES=$(client_LIB_DEPS)
ogl_SOURCES= noisetextures.c gl_textures.c gl_draw.c gl_dyn_fires.c \ ogl_SOURCES= noisetextures.c gl_textures.c gl_draw.c gl_dyn_fires.c \
gl_dyn_part.c gl_dyn_textures.c \ gl_dyn_part.c gl_dyn_textures.c \
gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \ gl_rlight.c gl_rmain.c gl_rmisc.c gl_rsurf.c \
gl_screen.c gl_sky.c gl_sky_clip gl_view.c gl_warp.c gl_screen.c gl_sky.c gl_sky_clip.c gl_view.c gl_warp.c
# ... 3Dfx Voodoo 1 and 2 SVGAlib-based console GL # ... 3Dfx Voodoo 1 and 2 SVGAlib-based console GL
nq_3dfx_SOURCES= $(combined_SOURCES) $(ogl_SOURCES) nq_3dfx_SOURCES= $(combined_SOURCES) $(ogl_SOURCES)

View file

@ -43,8 +43,6 @@
#include "glquake.h" #include "glquake.h"
#include "r_shared.h" #include "r_shared.h"
int r_dlightframecount;
/* /*
R_AnimateLight R_AnimateLight
*/ */
@ -121,7 +119,6 @@ R_RenderDlight (dlight_t *light)
VectorSubtract (light->origin, r_origin, v); VectorSubtract (light->origin, r_origin, v);
if (Length (v) < rad) { // view is inside the dlight if (Length (v) < rad) { // view is inside the dlight
AddLightBlend (1, 0.5, 0, light->radius * 0.0003);
return; return;
} }
@ -163,14 +160,11 @@ R_RenderDlights (void)
int i; int i;
dlight_t *l; dlight_t *l;
if (!gl_flashblend->int_val) if (!gl_dlight_polyblend->int_val)
return; return;
r_dlightframecount = r_framecount + 1; // because the count hasn't
// advanced yet for this frame
glDepthMask (GL_FALSE); glDepthMask (GL_FALSE);
glDisable (GL_TEXTURE_2D); glDisable (GL_TEXTURE_2D);
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE); glBlendFunc (GL_ONE, GL_ONE);
glShadeModel (GL_SMOOTH); glShadeModel (GL_SMOOTH);
@ -181,8 +175,9 @@ R_RenderDlights (void)
R_RenderDlight (l); R_RenderDlight (l);
} }
glColor3f (1, 1, 1); if (!gl_dlight_smooth->int_val)
glDisable (GL_BLEND); glShadeModel (GL_FLAT);
glColor3ubv (lighthalf_v);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask (GL_TRUE); glDepthMask (GL_TRUE);
@ -298,11 +293,9 @@ R_PushDlights (vec3_t entorigin)
dlight_t *l; dlight_t *l;
vec3_t lightorigin; vec3_t lightorigin;
if (gl_flashblend->int_val) if (!gl_dlight_lightmap->int_val)
return; return;
r_dlightframecount = r_framecount + 1; // because the count hasn't
// advanced yet for this frame
l = cl_dlights; l = cl_dlights;
for (i = 0; i < MAX_DLIGHTS; i++, l++) { for (i = 0; i < MAX_DLIGHTS; i++, l++) {

View file

@ -50,8 +50,10 @@
#include "chase.h" #include "chase.h"
#include "game.h" #include "game.h"
#include "glquake.h" #include "glquake.h"
#include "render.h" #include "r_cvar.h"
#include "r_local.h" #include "r_local.h"
#include "r_dynamic.h"
//#include "render.h"
#include "view.h" #include "view.h"
entity_t r_worldentity; entity_t r_worldentity;
@ -73,16 +75,13 @@ int c_brush_polys, c_alias_polys;
qboolean envmap; // true during envmap command capture qboolean envmap; // true during envmap command capture
int particletexture; // little dot for particles
int playertextures; // up to 16 color translated skins int playertextures; // up to 16 color translated skins
int mirrortexturenum; // quake texturenum, not gltexturenum int mirrortexturenum; // quake texturenum, not gltexturenum
qboolean mirror; qboolean mirror;
mplane_t *mirror_plane; mplane_t *mirror_plane;
//
// view origin // view origin
//
vec3_t vup; vec3_t vup;
vec3_t vpn; vec3_t vpn;
vec3_t vright; vec3_t vright;
@ -91,15 +90,15 @@ vec3_t r_origin;
float r_world_matrix[16]; float r_world_matrix[16];
float r_base_world_matrix[16]; float r_base_world_matrix[16];
//
// screen size info // screen size info
//
refdef_t r_refdef; refdef_t r_refdef;
mleaf_t *r_viewleaf, *r_oldviewleaf; mleaf_t *r_viewleaf, *r_oldviewleaf;
int d_lightstylevalue[256]; // 8.8 fraction of base light value int d_lightstylevalue[256]; // 8.8 fraction of base light value
vec3_t shadecolor; // Ender (EXtend) Colormod
float modelalpha; // Ender (EXtend) Alpha
void R_MarkLeaves (void); void R_MarkLeaves (void);
@ -109,12 +108,14 @@ extern byte gammatable[256];
extern qboolean lighthalf; extern qboolean lighthalf;
static float vid_gamma = 1.0; static float vid_gamma = 1.0;
// LordHavoc: place for gl_rmain setup code // LordHavoc: place for gl_rmain setup code
void void
glrmain_init () glrmain_init ()
{ {
}; };
/* /*
GL_CheckGamma GL_CheckGamma
@ -166,14 +167,6 @@ R_RotateForEntity (entity_t *e)
glRotatef (e->angles[2], 1, 0, 0); glRotatef (e->angles[2], 1, 0, 0);
} }
/*
=============================================================
SPRITE MODELS
=============================================================
*/
static mspriteframe_t * static mspriteframe_t *
R_GetSpriteFrame (entity_t *currententity) R_GetSpriteFrame (entity_t *currententity)
@ -242,11 +235,6 @@ R_DrawSpriteModel (entity_t *e)
right = vright; right = vright;
} }
if (lighthalf)
glColor4f (0.5, 0.5, 0.5, 1);
else
glColor4f (1, 1, 1, 1);
glBindTexture (GL_TEXTURE_2D, frame->gl_texturenum); glBindTexture (GL_TEXTURE_2D, frame->gl_texturenum);
glEnable (GL_ALPHA_TEST); glEnable (GL_ALPHA_TEST);
@ -279,11 +267,7 @@ R_DrawSpriteModel (entity_t *e)
/* /*
=============================================================
ALIAS MODELS ALIAS MODELS
=============================================================
*/ */
#define NUMVERTEXNORMALS 162 #define NUMVERTEXNORMALS 162
@ -297,9 +281,9 @@ float shadelight;
// precalculated dot products for quantized angles // precalculated dot products for quantized angles
#define SHADEDOT_QUANT 16 #define SHADEDOT_QUANT 16
float r_avertexnormal_dots[SHADEDOT_QUANT][256] = float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
#include "anorm_dots.h" #include "anorm_dots.h"
; ;
float *shadedots = r_avertexnormal_dots[0]; float *shadedots = r_avertexnormal_dots[0];
@ -320,20 +304,24 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
verts += posenum * paliashdr->poseverts; verts += posenum * paliashdr->poseverts;
order = (int *) ((byte *) paliashdr + paliashdr->commands); order = (int *) ((byte *) paliashdr + paliashdr->commands);
if (fb) if (modelalpha != 1.0)
glColor3f (1, 1, 1); glDepthMask (GL_FALSE);
else if (lighthalf)
shadelight *= 2; if (fb) {
while (1) { if (lighthalf)
glColor4f (0.5, 0.5, 0.5, modelalpha);
else
glColor4f (1, 1, 1, modelalpha);
}
while ((count = *order++)) {
// get the vertex count and primitive type // get the vertex count and primitive type
count = *order++;
if (!count)
break; // done
if (count < 0) { if (count < 0) {
count = -count; count = -count;
glBegin (GL_TRIANGLE_FAN); glBegin (GL_TRIANGLE_FAN);
} else } else {
glBegin (GL_TRIANGLE_STRIP); glBegin (GL_TRIANGLE_STRIP);
}
do { do {
// texture coordinates come from the draw list // texture coordinates come from the draw list
@ -343,7 +331,10 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
if (!fb) { if (!fb) {
// normals and vertexes come from the frame list // normals and vertexes come from the frame list
l = shadedots[verts->lightnormalindex] * shadelight; l = shadedots[verts->lightnormalindex] * shadelight;
glColor3f (l, l, l);
// LordHavoc: cleanup after Endy
glColor4f (shadecolor[0] * l, shadecolor[1] * l,
shadecolor[2] * l, modelalpha);
} }
glVertex3f (verts->v[0], verts->v[1], verts->v[2]); glVertex3f (verts->v[0], verts->v[1], verts->v[2]);
@ -352,8 +343,12 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
glEnd (); glEnd ();
} }
}
if (modelalpha != 1.0)
glDepthMask (GL_TRUE);
glColor3ubv (lighthalf_v);
}
extern vec3_t lightspot; extern vec3_t lightspot;
@ -376,11 +371,9 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
height = -lheight + 1.0; height = -lheight + 1.0;
while (1) { while ((count = *order++)) {
// get the vertex count and primitive type // get the vertex count and primitive type
count = *order++;
if (!count)
break; // done
if (count < 0) { if (count < 0) {
count = -count; count = -count;
glBegin (GL_TRIANGLE_FAN); glBegin (GL_TRIANGLE_FAN);
@ -464,10 +457,7 @@ R_DrawAliasModel (entity_t *e)
VectorCopy (currententity->origin, r_entorigin); VectorCopy (currententity->origin, r_entorigin);
VectorSubtract (r_origin, r_entorigin, modelorg); VectorSubtract (r_origin, r_entorigin, modelorg);
//
// get lighting information // get lighting information
//
shadelight = R_LightPoint (currententity->origin); shadelight = R_LightPoint (currententity->origin);
// always give the gun some light // always give the gun some light
@ -514,23 +504,15 @@ R_DrawAliasModel (entity_t *e)
shadevector[2] = 1; shadevector[2] = 1;
VectorNormalize (shadevector); VectorNormalize (shadevector);
//
// locate the proper data // locate the proper data
//
paliashdr = (aliashdr_t *) Mod_Extradata (currententity->model); paliashdr = (aliashdr_t *) Mod_Extradata (currententity->model);
c_alias_polys += paliashdr->mdl.numtris; c_alias_polys += paliashdr->mdl.numtris;
//
// draw all the triangles // draw all the triangles
//
glPushMatrix (); glPushMatrix ();
R_RotateForEntity (e); R_RotateForEntity (e);
// LordHavoc: must be in modulate mode for reasons of lighting as well as // LordHavoc: must be in modulate mode for reasons of lighting as well as
//
//
// fullbright support // fullbright support
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -605,8 +587,6 @@ R_DrawAliasModel (entity_t *e)
} }
//==================================================================================
static void static void
R_DrawEntitiesOnList (void) R_DrawEntitiesOnList (void)
@ -769,9 +749,7 @@ R_SetupGL (void)
extern int glwidth, glheight; extern int glwidth, glheight;
int x, x2, y2, y, w, h; int x, x2, y2, y, w, h;
//
// set up viewpoint // set up viewpoint
//
glMatrixMode (GL_PROJECTION); glMatrixMode (GL_PROJECTION);
glLoadIdentity (); glLoadIdentity ();
x = r_refdef.vrect.x * glwidth / vid.width; x = r_refdef.vrect.x * glwidth / vid.width;
@ -829,9 +807,7 @@ R_SetupGL (void)
glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix); glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
//
// set drawing parms // set drawing parms
//
if (gl_cull->int_val) if (gl_cull->int_val)
glEnable (GL_CULL_FACE); glEnable (GL_CULL_FACE);
else else
@ -845,38 +821,6 @@ R_SetupGL (void)
} }
/*
================
R_RenderScene
r_refdef must be set before the first call
================
*/
static void
R_RenderScene (void)
{
R_SetupFrame ();
R_SetFrustum ();
R_SetupGL ();
R_MarkLeaves (); // done here so we know if we're in
// water
R_DrawWorld (); // adds static entities to the list
S_ExtraUpdate (); // don't let sound get messed up if
// going slow
R_DrawEntitiesOnList ();
R_RenderDlights ();
R_UpdateFires ();
R_DrawParticles ();
}
static void static void
R_Clear (void) R_Clear (void)
{ {
@ -891,6 +835,7 @@ R_Clear (void)
glDepthRange (gldepthmin, gldepthmax); glDepthRange (gldepthmin, gldepthmax);
} }
#if 0 // !!! FIXME, Zoid, mirror is disabled for now #if 0 // !!! FIXME, Zoid, mirror is disabled for now
void void
R_Mirror (void) R_Mirror (void)
@ -958,11 +903,9 @@ R_Mirror (void)
/* /*
================ R_RenderView
R_RenderView
r_refdef must be set before the first call r_refdef must be set before the first call
================
*/ */
void void
R_RenderView (void) R_RenderView (void)
@ -980,10 +923,30 @@ R_RenderView (void)
R_Clear (); R_Clear ();
// render normal view // render normal view
R_RenderScene (); R_SetupFrame ();
R_DrawViewModel ();
R_SetFrustum ();
R_SetupGL ();
R_MarkLeaves (); // done here so we know if we're in water
R_DrawWorld (); // adds static entities to the list
S_ExtraUpdate (); // don't let sound get messed up if going slow
R_DrawEntitiesOnList ();
R_RenderDlights ();
R_DrawWaterSurfaces (); R_DrawWaterSurfaces ();
R_UpdateFires ();
R_DrawParticles ();
R_DrawViewModel ();
// render mirror view // render mirror view
// R_Mirror (); // R_Mirror ();
} }

View file

@ -58,15 +58,17 @@
#include "r_local.h" #include "r_local.h"
#include "render.h" #include "render.h"
extern entity_t r_worldentity;
extern void GDT_Init ();
varray_t2f_c4f_v3f_t varray[MAX_VARRAY_VERTS]; varray_t2f_c4f_v3f_t varray[MAX_VARRAY_VERTS];
qboolean VID_Is8bit (void); qboolean VID_Is8bit (void);
void R_InitBubble ();
qboolean allowskybox; // allow skyboxes? --KB qboolean allowskybox; // allow skyboxes? --KB
void R_InitBubble (void);
extern cvar_t *r_netgraph;
extern void GDT_Init ();
extern entity_t r_worldentity;
void void
@ -75,7 +77,7 @@ R_InitTextures (void)
int x, y, m; int x, y, m;
byte *dest; byte *dest;
// create a simple checkerboard texture for the default // create a simple checkerboard texture for the default
r_notexture_mip = r_notexture_mip =
Hunk_AllocName (sizeof (texture_t) + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2, Hunk_AllocName (sizeof (texture_t) + 16 * 16 + 8 * 8 + 4 * 4 + 2 * 2,
"notexture"); "notexture");
@ -89,13 +91,14 @@ R_InitTextures (void)
for (m = 0; m < 4; m++) { for (m = 0; m < 4; m++) {
dest = (byte *) r_notexture_mip + r_notexture_mip->offsets[m]; dest = (byte *) r_notexture_mip + r_notexture_mip->offsets[m];
for (y = 0; y < (16 >> m); y++) for (y = 0; y < (16 >> m); y++) {
for (x = 0; x < (16 >> m); x++) { for (x = 0; x < (16 >> m); x++) {
if ((y < (8 >> m)) ^ (x < (8 >> m))) if ((y < (8 >> m)) ^ (x < (8 >> m)))
*dest++ = 0; *dest++ = 0;
else else
*dest++ = 0xff; *dest++ = 0xff;
} }
}
} }
} }
@ -182,12 +185,14 @@ void
R_Init (void) R_Init (void)
{ {
allowskybox = false; // server will decide if this is allowskybox = false; // server will decide if this is
// allowed --KB // allowed --KB
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "No Description"); Cmd_AddCommand ("timerefresh", R_TimeRefresh_f,
"Tests the current refresh rate for the current location");
Cmd_AddCommand ("envmap", R_Envmap_f, "No Description"); Cmd_AddCommand ("envmap", R_Envmap_f, "No Description");
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "No Description"); Cmd_AddCommand ("pointfile", R_ReadPointFile_f,
Cmd_AddCommand ("loadsky", R_LoadSky_f, "No Description"); "Load a pointfile to determine map leaks");
Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox");
R_InitBubble (); R_InitBubble ();
@ -199,11 +204,9 @@ R_Init (void)
/* /*
=============== R_TranslatePlayerSkin
R_TranslatePlayerSkin
Translates a skin texture by the per-player color lookup Translates a skin texture by the per-player color lookup
===============
*/ */
void void
R_TranslatePlayerSkin (int playernum) R_TranslatePlayerSkin (int playernum)
@ -351,7 +354,8 @@ R_TranslatePlayerSkin (int playernum)
void void
R_NewMap (void) R_NewMap (void)
{ {
int i; int i;
cvar_t *r_skyname;
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
d_lightstylevalue[i] = 264; // normal light value d_lightstylevalue[i] = 264; // normal light value
@ -359,8 +363,7 @@ R_NewMap (void)
memset (&r_worldentity, 0, sizeof (r_worldentity)); memset (&r_worldentity, 0, sizeof (r_worldentity));
r_worldentity.model = cl.worldmodel; r_worldentity.model = cl.worldmodel;
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
// FIXME: is this one short?
for (i = 0; i < cl.worldmodel->numleafs; i++) for (i = 0; i < cl.worldmodel->numleafs; i++)
cl.worldmodel->leafs[i].efrags = NULL; cl.worldmodel->leafs[i].efrags = NULL;
@ -390,11 +393,9 @@ R_NewMap (void)
/* /*
==================== R_TimeRefresh_f
R_TimeRefresh_f
For program optimization For program optimization
====================
*/ */
// LordHavoc: improved appearance and accuracy of timerefresh // LordHavoc: improved appearance and accuracy of timerefresh
void void
@ -403,7 +404,6 @@ R_TimeRefresh_f (void)
int i; int i;
double start, stop, time; double start, stop, time;
// glDrawBuffer (GL_FRONT);
glFinish (); glFinish ();
GL_EndRendering (); GL_EndRendering ();
@ -416,13 +416,10 @@ R_TimeRefresh_f (void)
GL_EndRendering (); GL_EndRendering ();
} }
// glFinish ();
stop = Sys_DoubleTime (); stop = Sys_DoubleTime ();
time = stop - start; time = stop - start;
Con_Printf ("%f seconds (%f fps)\n", time, 128 / time); Con_Printf ("%f seconds (%f fps)\n", time, 128 / time);
// glDrawBuffer (GL_BACK);
// GL_EndRendering ();
GL_BeginRendering (&glx, &gly, &glwidth, &glheight); GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
} }

View file

@ -40,35 +40,26 @@
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include "QF/cmd.h"
#include "QF/compat.h" #include "QF/compat.h"
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/draw.h"
#include "QF/mathlib.h"
#include "QF/model.h"
#include "QF/qargs.h"
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/vid.h"
#include "QF/wad.h"
#include "protocol.h"
#include "client.h" #include "client.h"
#include "glquake.h" #include "glquake.h"
#include "r_cvar.h" #include "r_cvar.h"
#include "r_local.h" #include "r_local.h"
#include "render.h" #include "r_shared.h"
#include "sbar.h"
qboolean r_cache_thrash;
extern double realtime; extern double realtime;
int skytexturenum; int skytexturenum;
extern vec3_t shadecolor; // Ender (Extend) Colormod extern vec3_t shadecolor; // Ender (Extend) Colormod
int lightmap_bytes; // 1 or 3
int lightmap_bytes; // 1, 3, or 4
int lightmap_textures; int lightmap_textures;
unsigned blocklights[18 * 18 * 3]; unsigned int blocklights[18 * 18 * 3];
#define BLOCK_WIDTH 128 #define BLOCK_WIDTH 128
#define BLOCK_HEIGHT 128 #define BLOCK_HEIGHT 128
@ -94,28 +85,29 @@ int allocated[MAX_LIGHTMAPS][BLOCK_WIDTH];
byte *lightmaps[MAX_LIGHTMAPS]; byte *lightmaps[MAX_LIGHTMAPS];
msurface_t *waterchain = NULL; msurface_t *waterchain = NULL;
msurface_t *sky_chain;
extern qboolean lighthalf; extern qboolean lighthalf;
// LordHavoc: place for gl_rsurf setup code // LordHavoc: place for gl_rsurf setup code
void void
glrsurf_init () glrsurf_init (void)
{ {
memset (&lightmaps, 0, sizeof (lightmaps)); memset (&lightmaps, 0, sizeof (lightmaps));
} }
void static void
recursivelightupdate (mnode_t *node) R_RecursiveLightUpdate (mnode_t *node)
{ {
int c; int c;
msurface_t *surf; msurface_t *surf;
if (node->children[0]->contents >= 0) if (node->children[0]->contents >= 0)
recursivelightupdate (node->children[0]); R_RecursiveLightUpdate (node->children[0]);
if (node->children[1]->contents >= 0) if (node->children[1]->contents >= 0)
recursivelightupdate (node->children[1]); R_RecursiveLightUpdate (node->children[1]);
if ((c = node->numsurfaces)) if ((c = node->numsurfaces))
for (surf = cl.worldmodel->surfaces + node->firstsurface; c; for (surf = cl.worldmodel->surfaces + node->firstsurface; c;
c--, surf++) surf->cached_dlight = true; c--, surf++) surf->cached_dlight = true;
@ -124,30 +116,29 @@ recursivelightupdate (mnode_t *node)
// LordHavoc: function to force all lightmaps to be updated // LordHavoc: function to force all lightmaps to be updated
void void
R_ForceLightUpdate () R_ForceLightUpdate (void)
{ {
if (cl.worldmodel && cl.worldmodel->nodes if (cl.worldmodel && cl.worldmodel->nodes
&& cl.worldmodel->nodes->contents >= 0) && cl.worldmodel->nodes->contents >= 0)
recursivelightupdate (cl.worldmodel->nodes); R_RecursiveLightUpdate (cl.worldmodel->nodes);
} }
int dlightdivtable[8192];
int dlightdivtableinitialized = 0;
/* /*
R_AddDynamicLights R_AddDynamicLights
LordHavoc: completely rewrote this, relies on 64bit integer math... LordHavoc: completely rewrote this, relies on 64bit integer math...
*/ */
int dlightdivtable[8192];
int dlightdivtableinitialized = 0;
void void
R_AddDynamicLights (msurface_t *surf) R_AddDynamicLights (msurface_t *surf)
{ {
int sdtable[18], lnum, td, maxdist, maxdist2, maxdist3, i, s, t, int sdtable[18], lnum, td, maxdist, maxdist2, maxdist3, i, s, t,
smax, tmax, red, green, blue, j; smax, tmax, red, green, blue, j;
unsigned *bl; unsigned int *bl;
float dist, f; float dist, f;
vec3_t impact, local; vec3_t impact, local;
@ -178,58 +169,40 @@ R_AddDynamicLights (msurface_t *surf)
impact[i] = impact[i] =
cl_dlights[lnum].origin[i] - surf->plane->normal[i] * dist; cl_dlights[lnum].origin[i] - surf->plane->normal[i] * dist;
f = i = f = DotProduct (impact, surf->texinfo->vecs[0]) +
DotProduct (impact, surf->texinfo->vecs[0][3] - surf->texturemins[0];
surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] -
surf->texturemins[0];
i = f;
// reduce calculations // reduce calculations
t = dist * dist; t = dist * dist;
for (s = 0; s < smax; s++, i -= 16) for (s = 0; s < smax; s++, i -= 16)
sdtable[s] = i * i + t; sdtable[s] = i * i + t;
f = i = f = DotProduct (impact, surf->texinfo->vecs[1]) +
DotProduct (impact, surf->texinfo->vecs[1][3] - surf->texturemins[1];
surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] -
surf->texturemins[1];
i = f;
maxdist = (int) (cl_dlights[lnum].radius * cl_dlights[lnum].radius);
// for comparisons to minimum acceptable light // for comparisons to minimum acceptable light
maxdist = (int) ((cl_dlights[lnum].radius * cl_dlights[lnum].radius) * 0.75);
// clamp radius to avoid exceeding 8192 entry division table // clamp radius to avoid exceeding 8192 entry division table
if (maxdist > 1048576) if (maxdist > 1048576)
maxdist = 1048576; maxdist = 1048576;
maxdist3 = maxdist - (int) (dist * dist); maxdist3 = maxdist - (int) (dist * dist);
// convert to 8.8 blocklights format // convert to 8.8 blocklights format
// if (!cl_dlights[lnum].dark) red = f = cl_dlights[lnum].color[0] * maxdist;
// { green = f = cl_dlights[lnum].color[1] * maxdist;
f = cl_dlights[lnum].color[0] * maxdist; blue = f = cl_dlights[lnum].color[2] * maxdist;
red = f;
f = cl_dlights[lnum].color[1] * maxdist;
green = f;
f = cl_dlights[lnum].color[2] * maxdist;
blue = f;
/*
} else // negate for darklight { f = cl_dlights[lnum].color[0] *
-maxdist;red = f; f = cl_dlights[lnum].color[1] * -maxdist;green =
f; f = cl_dlights[lnum].color[2] * -maxdist;blue = f; } */
bl = blocklights; bl = blocklights;
for (t = 0; t < tmax; t++, i -= 16) { for (t = 0; t < tmax; t++, i -= 16) {
td = i * i; td = i * i;
if (td < maxdist3) // make sure some part of it is if (td < maxdist3) { // make sure some part of it is visible on this line
// visible on this line
{
maxdist2 = maxdist - td; maxdist2 = maxdist - td;
for (s = 0; s < smax; s++) { for (s = 0; s < smax; s++) {
if (sdtable[s] < maxdist2) { if (sdtable[s] < maxdist2) {
j = dlightdivtable[(sdtable[s] + td) >> 7]; j = dlightdivtable[(sdtable[s] + td) >> 7];
k = (red * j) >> 7; bl[0] += (k = (red * j) >> 7);
bl[0] += k; bl[1] += (k = (green * j) >> 7);
k = (green * j) >> 7; bl[2] += (k = (blue * j) >> 7);
bl[1] += k;
k = (blue * j) >> 7;
bl[2] += k;
} }
bl += 3; bl += 3;
} }
@ -252,13 +225,12 @@ void
R_BuildLightMap (msurface_t *surf, byte * dest, int stride) R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
{ {
int smax, tmax; int smax, tmax;
int t; int i, j, size, shift;
int i, j, size;
byte *lightmap; byte *lightmap;
unsigned scale; unsigned int scale;
int maps; int maps;
float t2; float t2;
unsigned *bl; unsigned int *bl;
surf->cached_dlight = (surf->dlightframe == r_framecount); surf->cached_dlight = (surf->dlightframe == r_framecount);
@ -268,26 +240,16 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
lightmap = surf->samples; lightmap = surf->samples;
// set to full bright if no light data // set to full bright if no light data
if ( /* r_fullbright->int_val || */ !cl.worldmodel->lightdata) { if (!cl.worldmodel->lightdata) {
bl = blocklights; memset (&blocklights[0], 65280, 3 * size * sizeof(int));
for (i = 0; i < size; i++) {
*bl++ = 255 * 256;
*bl++ = 255 * 256;
*bl++ = 255 * 256;
}
goto store; goto store;
} }
// clear to no light // clear to no light
bl = blocklights; memset (&blocklights[0], 0, 3 * size * sizeof(int));
for (i = 0; i < size; i++) {
*bl++ = 0;
*bl++ = 0;
*bl++ = 0;
}
bl = blocklights;
// add all the lightmaps // add all the lightmaps
if (lightmap) if (lightmap) {
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) { for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++) {
scale = d_lightstylevalue[surf->styles[maps]]; scale = d_lightstylevalue[surf->styles[maps]];
surf->cached_light[maps] = scale; // 8.8 fraction surf->cached_light[maps] = scale; // 8.8 fraction
@ -298,64 +260,58 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
*bl++ += *lightmap++ * scale; *bl++ += *lightmap++ * scale;
} }
} }
}
// add all the dynamic lights // add all the dynamic lights
if (surf->dlightframe == r_framecount) if (surf->dlightframe == r_framecount)
R_AddDynamicLights (surf); R_AddDynamicLights (surf);
store: store:
// bound and shift // bound and shift
if (gl_colorlights->int_val) { stride -= smax * lightmap_bytes;
stride -= smax * 3; bl = blocklights;
bl = blocklights;
if (lighthalf) { if (gl_mtex_active && !lighthalf) {
for (i = 0; i < tmax; i++, dest += stride) shift = 7; // 0-1 lightmap range.
for (j = 0; j < smax; j++) {
t = (int) *bl++ >> 8;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 8;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 8;
*dest++ = bound (0, t, 255);
}
} else {
for (i = 0; i < tmax; i++, dest += stride)
for (j = 0; j < smax; j++) {
t = (int) *bl++ >> 7;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 7;
*dest++ = bound (0, t, 255);
t = (int) *bl++ >> 7;
*dest++ = bound (0, t, 255);
}
}
} else { } else {
stride -= smax; shift = 8; // 0-2 lightmap range.
bl = blocklights; }
if (lighthalf) {
for (i = 0; i < tmax; i++, dest += stride) switch (lightmap_bytes) {
for (j = 0; j < smax; j++) { case 4:
t = (int) *bl++ >> 8; for (i = 0; i < tmax; i++, dest += stride) {
t2 = bound (0, t, 255); for (j = 0; j < smax; j++) {
t = (int) *bl++ >> 8; dest[0] = bound(0, bl[0] >> shift, 255);
t2 += bound (0, t, 255); dest[1] = bound(0, bl[1] >> shift, 255);
t = (int) *bl++ >> 8; dest[2] = bound(0, bl[2] >> shift, 255);
t2 += bound (0, t, 255); dest[3] = 255;
t2 *= (1.0 / 3.0); dest += 4;
*dest++ = t2; bl += 3;
} }
} else {
for (i = 0; i < tmax; i++, dest += stride)
for (j = 0; j < smax; j++) {
t = (int) *bl++ >> 7;
t2 = bound (0, t, 255);
t = (int) *bl++ >> 7;
t2 += bound (0, t, 255);
t = (int) *bl++ >> 7;
t2 += bound (0, t, 255);
t2 *= (1.0 / 3.0);
*dest++ = t2;
}
} }
break;
case 3:
for (i = 0; i < tmax; i++, dest += stride) {
for (j = 0; j < smax; j++) {
dest[0] = bound(0, bl[0] >> shift, 255);
dest[1] = bound(0, bl[1] >> shift, 255);
dest[2] = bound(0, bl[2] >> shift, 255);
dest += 3;
bl += 3;
}
}
break;
case 1:
for (i = 0; i < tmax; i++, dest += stride) {
for (j = 0; j < smax; j++) {
t2 = bound (0, bl[0] >> shift, 255);
t2 += bound (0, bl[1] >> shift, 255);
t2 += bound (0, bl[2] >> shift, 255);
t2 *= (1.0 / 3.0);
*dest++ = t2;
bl += 3;
}
}
break;
} }
} }
@ -403,16 +359,17 @@ extern int solidskytexture;
extern int alphaskytexture; extern int alphaskytexture;
extern float speedscale; // for top sky and bottom sky extern float speedscale; // for top sky and bottom sky
lpMTexFUNC qglMTexCoord2f = NULL;
lpSelTexFUNC qglSelectTexture = NULL;
void void
GL_UploadLightmap (int i, int x, int y, int w, int h) GL_UploadLightmap (int i, int x, int y, int w, int h)
{ {
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, y, BLOCK_WIDTH, h, gl_lightmap_format, /* glTexSubImage2D (GL_TEXTURE_2D, 0, 0, y, BLOCK_WIDTH, h, gl_lightmap_format,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
lightmaps[i] + (y * BLOCK_WIDTH) * lightmap_bytes); lightmaps[i] + (y * BLOCK_WIDTH) * lightmap_bytes);
*/
glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH,
BLOCK_HEIGHT, 0, gl_lightmap_format,
GL_UNSIGNED_BYTE, lightmaps[i]);
} }
@ -436,12 +393,12 @@ R_DrawMultitexturePoly (msurface_t *s)
glColor3f (1, 1, 1); glColor3f (1, 1, 1);
// Binds world to texture env 0 // Binds world to texture env 0
qglSelectTexture (gl_mtex_enum + 0); qglActiveTexture (gl_mtex_enum + 0);
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum); glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
// Binds lightmap to texenv 1 // Binds lightmap to texenv 1
qglSelectTexture (gl_mtex_enum + 1); qglActiveTexture (gl_mtex_enum + 1);
glBindTexture (GL_TEXTURE_2D, lightmap_textures + i); glBindTexture (GL_TEXTURE_2D, lightmap_textures + i);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
@ -452,9 +409,7 @@ R_DrawMultitexturePoly (msurface_t *s)
if (d_lightstylevalue[s->styles[maps]] != s->cached_light[maps]) if (d_lightstylevalue[s->styles[maps]] != s->cached_light[maps])
goto dynamic; goto dynamic;
if (s->dlightframe == r_framecount // dynamic this frame if ((s->dlightframe == r_framecount) || s->cached_dlight) {
|| s->cached_dlight) // dynamic previously
{
dynamic: dynamic:
R_BuildLightMap (s, R_BuildLightMap (s,
lightmaps[s->lightmaptexturenum] + lightmaps[s->lightmaptexturenum] +
@ -470,19 +425,21 @@ R_DrawMultitexturePoly (msurface_t *s)
glBegin (GL_POLYGON); glBegin (GL_POLYGON);
v = s->polys->verts[0]; v = s->polys->verts[0];
for (i = 0; i < s->polys->numverts; i++, v += VERTEXSIZE) { for (i = 0; i < s->polys->numverts; i++, v += VERTEXSIZE) {
qglMTexCoord2f (gl_mtex_enum + 0, v[3], v[4]); qglMultiTexCoord2f (gl_mtex_enum + 0, v[3], v[4]);
qglMTexCoord2f (gl_mtex_enum + 1, v[5], v[6]); qglMultiTexCoord2f (gl_mtex_enum + 1, v[5], v[6]);
glVertex3fv (v); glVertex3fv (v);
} }
glEnd (); glEnd ();
glDisable (GL_TEXTURE_2D); glDisable (GL_TEXTURE_2D);
qglSelectTexture (gl_mtex_enum + 0); qglActiveTexture (gl_mtex_enum + 0);
glEnable (GL_TEXTURE_2D); glEnable (GL_TEXTURE_2D);
if (texture->gl_fb_texturenum > 0) { if (texture->gl_fb_texturenum > 0) {
s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum]; s->polys->fb_chain = fullbright_polys[texture->gl_fb_texturenum];
fullbright_polys[texture->gl_fb_texturenum] = s->polys; fullbright_polys[texture->gl_fb_texturenum] = s->polys;
} }
glColor3ubv (lighthalf_v);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} }
@ -493,11 +450,14 @@ R_BlendLightmaps (void)
glpoly_t *p; glpoly_t *p;
float *v; float *v;
glDepthMask (0); // don't bother writing Z glDepthMask (GL_FALSE); // don't bother writing Z
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (lighthalf)
glBlendFunc (GL_ZERO, GL_SRC_COLOR); glBlendFunc (GL_ZERO, GL_SRC_COLOR);
glEnable (GL_BLEND); else
glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR);
glColor3f (1, 1, 1);
for (i = 0; i < MAX_LIGHTMAPS; i++) { for (i = 0; i < MAX_LIGHTMAPS; i++) {
p = lightmap_polys[i]; p = lightmap_polys[i];
@ -523,9 +483,10 @@ R_BlendLightmaps (void)
} }
// Return to normal blending --KB // Return to normal blending --KB
glColor3ubv (lighthalf_v);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask (1); // back to normal Z buffering glDepthMask (GL_TRUE); // back to normal Z buffering
} }
@ -536,10 +497,7 @@ R_RenderFullbrights (void)
glpoly_t *p; glpoly_t *p;
float *v; float *v;
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBlendFunc (GL_ONE, GL_ONE); glBlendFunc (GL_ONE, GL_ONE);
glEnable (GL_BLEND);
glColor3f (1, 1, 1);
for (i = 1; i < MAX_GLTEXTURES; i++) { for (i = 1; i < MAX_GLTEXTURES; i++) {
if (!fullbright_polys[i]) if (!fullbright_polys[i])
@ -554,8 +512,6 @@ R_RenderFullbrights (void)
glEnd (); glEnd ();
} }
} }
glDisable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
@ -573,6 +529,7 @@ R_RenderBrushPoly (msurface_t *fa)
c_brush_polys++; c_brush_polys++;
glColor3f (1, 1, 1);
glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum); glBindTexture (GL_TEXTURE_2D, texture->gl_texturenum);
glBegin (GL_POLYGON); glBegin (GL_POLYGON);
@ -597,9 +554,7 @@ R_RenderBrushPoly (msurface_t *fa)
if (d_lightstylevalue[fa->styles[maps]] != fa->cached_light[maps]) if (d_lightstylevalue[fa->styles[maps]] != fa->cached_light[maps])
goto dynamic; goto dynamic;
if (fa->dlightframe == r_framecount // dynamic this frame if ((fa->dlightframe == r_framecount) || fa->cached_dlight) {
|| fa->cached_dlight) // dynamic previously
{
dynamic: dynamic:
if (r_dynamic->int_val) { if (r_dynamic->int_val) {
lightmap_modified[fa->lightmaptexturenum] = true; lightmap_modified[fa->lightmaptexturenum] = true;
@ -621,12 +576,12 @@ R_RenderBrushPoly (msurface_t *fa)
if ((theRect->h + theRect->t) < (fa->light_t + tmax)) if ((theRect->h + theRect->t) < (fa->light_t + tmax))
theRect->h = (fa->light_t - theRect->t) + tmax; theRect->h = (fa->light_t - theRect->t) + tmax;
base = base =
lightmaps[fa->lightmaptexturenum] + (fa->light_t * BLOCK_WIDTH + lightmaps[fa->lightmaptexturenum] +
fa->light_s) * (fa->light_t * BLOCK_WIDTH + fa->light_s) * lightmap_bytes;
lightmap_bytes;
R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes); R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes);
} }
} }
glColor3ubv (lighthalf_v);
} }
@ -635,20 +590,20 @@ GL_WaterSurface (msurface_t *s)
{ {
int i; int i;
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (lighthalf)
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
else
glColor4f (1, 1, 1, r_wateralpha->value);
i = s->texinfo->texture->gl_texturenum; i = s->texinfo->texture->gl_texturenum;
glBindTexture (GL_TEXTURE_2D, i); glBindTexture (GL_TEXTURE_2D, i);
if (r_wateralpha->value < 1.0) { if (r_wateralpha->value < 1.0) {
glDepthMask (0); glDepthMask (GL_FALSE);
if (lighthalf) {
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
} else {
glColor4f (1, 1, 1, r_wateralpha->value);
}
EmitWaterPolys (s); EmitWaterPolys (s);
glDepthMask (1); glColor3ubv (lighthalf_v);
glDepthMask (GL_TRUE);
} else } else
EmitWaterPolys (s); EmitWaterPolys (s);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
} }
@ -662,16 +617,16 @@ R_DrawWaterSurfaces (void)
return; return;
// go back to the world matrix // go back to the world matrix
glLoadMatrixf (r_world_matrix); glLoadMatrixf (r_world_matrix);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (r_wateralpha->value < 1.0) {
if (lighthalf) glDepthMask (GL_FALSE);
glColor4f (0.5, 0.5, 0.5, r_wateralpha->value); if (lighthalf) {
else glColor4f (0.5, 0.5, 0.5, r_wateralpha->value);
glColor4f (1, 1, 1, r_wateralpha->value); } else {
if (r_wateralpha->value < 1.0) glColor4f (1, 1, 1, r_wateralpha->value);
glDepthMask (0); }
}
i = -1; i = -1;
for (s = waterchain; s; s = s->texturechain) { for (s = waterchain; s; s = s->texturechain) {
@ -684,9 +639,10 @@ R_DrawWaterSurfaces (void)
waterchain = NULL; waterchain = NULL;
glColor3f (1, 1, 1); if (r_wateralpha->value < 1.0) {
if (r_wateralpha->value < 1.0) glDepthMask (GL_TRUE);
glDepthMask (1); glColor3ubv (lighthalf_v);
}
} }
@ -696,6 +652,8 @@ DrawTextureChains (void)
int i; int i;
msurface_t *s; msurface_t *s;
glDisable (GL_BLEND);
for (i = 0; i < cl.worldmodel->numtextures; i++) { for (i = 0; i < cl.worldmodel->numtextures; i++) {
if (!cl.worldmodel->textures[i]) if (!cl.worldmodel->textures[i])
continue; continue;
@ -704,6 +662,8 @@ DrawTextureChains (void)
cl.worldmodel->textures[i]->texturechain = NULL; cl.worldmodel->textures[i]->texturechain = NULL;
} }
glEnable (GL_BLEND);
} }
@ -738,10 +698,11 @@ R_DrawBrushModel (entity_t *e)
if (R_CullBox (mins, maxs)) if (R_CullBox (mins, maxs))
return; return;
glColor3f (1, 1, 1);
memset (lightmap_polys, 0, sizeof (lightmap_polys)); memset (lightmap_polys, 0, sizeof (lightmap_polys));
memset (fullbright_polys, 0, sizeof (fullbright_polys)); memset (fullbright_polys, 0, sizeof (fullbright_polys));
if (gl_sky_clip->int_val) {
sky_chain = 0;
}
VectorSubtract (r_refdef.vieworg, e->origin, modelorg); VectorSubtract (r_refdef.vieworg, e->origin, modelorg);
if (rotated) { if (rotated) {
@ -757,9 +718,8 @@ R_DrawBrushModel (entity_t *e)
psurf = &clmodel->surfaces[clmodel->firstmodelsurface]; psurf = &clmodel->surfaces[clmodel->firstmodelsurface];
// calculate dynamic lighting for bmodel if it's not an // calculate dynamic lighting for bmodel if it's not an instanced model
// instanced model if (clmodel->firstmodelsurface != 0 && gl_dlight_lightmap->int_val) {
if (clmodel->firstmodelsurface != 0 && !gl_flashblend->int_val) {
vec3_t lightorigin; vec3_t lightorigin;
for (k = 0; k < MAX_DLIGHTS; k++) { for (k = 0; k < MAX_DLIGHTS; k++) {
@ -777,14 +737,12 @@ R_DrawBrushModel (entity_t *e)
R_RotateForEntity (e); R_RotateForEntity (e);
e->angles[0] = -e->angles[0]; // stupid quake bug e->angles[0] = -e->angles[0]; // stupid quake bug
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//
// draw texture // draw texture
//
for (i = 0; i < clmodel->nummodelsurfaces; i++, psurf++) { for (i = 0; i < clmodel->nummodelsurfaces; i++, psurf++) {
/* FIXME: Not in qw?
if (psurf->flags & SURF_DRAWSKY) if (psurf->flags & SURF_DRAWSKY)
return; return;
*/
// find which side of the node we are on // find which side of the node we are on
pplane = psurf->plane; pplane = psurf->plane;
@ -794,24 +752,28 @@ R_DrawBrushModel (entity_t *e)
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) { (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
if (psurf->flags & SURF_DRAWTURB) if (psurf->flags & SURF_DRAWTURB) {
GL_WaterSurface (psurf); GL_WaterSurface (psurf);
else if (gl_texsort->int_val) } else if (psurf->flags & SURF_DRAWSKY) {
R_RenderBrushPoly (psurf); psurf->texturechain = sky_chain;
else sky_chain = psurf;
return;
} else if (gl_mtex_active) {
R_DrawMultitexturePoly (psurf); R_DrawMultitexturePoly (psurf);
} else {
R_RenderBrushPoly (psurf);
}
} }
} }
if (gl_texsort->int_val) if (!gl_mtex_active)
R_BlendLightmaps (); R_BlendLightmaps ();
if (gl_fb_bmodels->int_val) if (gl_fb_bmodels->int_val)
R_RenderFullbrights (); R_RenderFullbrights ();
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (gl_sky_clip->int_val)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); R_DrawSkyChain (sky_chain);
glEnable (GL_BLEND);
glPopMatrix (); glPopMatrix ();
} }
@ -832,14 +794,13 @@ R_RecursiveWorldNode (mnode_t *node)
double dot; double dot;
if (node->contents == CONTENTS_SOLID) if (node->contents == CONTENTS_SOLID)
return; // solid return;
if (node->visframe != r_visframecount) if (node->visframe != r_visframecount)
return; return;
if (R_CullBox (node->minmaxs, node->minmaxs + 3)) if (R_CullBox (node->minmaxs, node->minmaxs + 3))
return; return;
// if a leaf node, draw stuff // if a leaf node, draw stuff
if (node->contents < 0) { if (node->contents < 0) {
pleaf = (mleaf_t *) node; pleaf = (mleaf_t *) node;
@ -856,9 +817,9 @@ R_RecursiveWorldNode (mnode_t *node)
return; return;
} }
// node is just a decision point, so go down the apropriate sides // node is just a decision point, so go down the apropriate sides
// find which side of the node we are on // find which side of the node we are on
plane = node->plane; plane = node->plane;
switch (plane->type) { switch (plane->type) {
@ -878,7 +839,7 @@ R_RecursiveWorldNode (mnode_t *node)
side = dot < 0; side = dot < 0;
// recurse down the children, front side first // recurse down the children, front side first
// LordHavoc: save a stack frame by avoiding a call // LordHavoc: save a stack frame by avoiding a call
if (node->children[side]->contents != CONTENTS_SOLID if (node->children[side]->contents != CONTENTS_SOLID
&& node->children[side]->visframe == r_visframecount && node->children[side]->visframe == r_visframecount
@ -886,7 +847,7 @@ R_RecursiveWorldNode (mnode_t *node)
node->children[side]->minmaxs + 3)) node->children[side]->minmaxs + 3))
R_RecursiveWorldNode (node->children[side]); R_RecursiveWorldNode (node->children[side]);
// draw stuff // draw stuff
if ((c = node->numsurfaces)) { if ((c = node->numsurfaces)) {
surf = cl.worldmodel->surfaces + node->firstsurface; surf = cl.worldmodel->surfaces + node->firstsurface;
@ -902,20 +863,22 @@ R_RecursiveWorldNode (mnode_t *node)
if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK))
continue; // wrong side continue; // wrong side
if (surf->flags & SURF_DRAWSKY)
continue;
if (surf->flags & SURF_DRAWTURB) { if (surf->flags & SURF_DRAWTURB) {
surf->texturechain = waterchain; surf->texturechain = waterchain;
waterchain = surf; waterchain = surf;
} else if (gl_texsort->int_val) { } else if (surf->flags & SURF_DRAWSKY) {
surf->texturechain = sky_chain;
sky_chain = surf;
continue;
} else if (gl_mtex_active) {
R_DrawMultitexturePoly (surf);
} else {
surf->texturechain = surf->texinfo->texture->texturechain; surf->texturechain = surf->texinfo->texture->texturechain;
surf->texinfo->texture->texturechain = surf; surf->texinfo->texture->texturechain = surf;
} else }
R_DrawMultitexturePoly (surf);
} }
} }
// recurse down the back side // recurse down the back side
// LordHavoc: save a stack frame by avoiding a call // LordHavoc: save a stack frame by avoiding a call
side = !side; side = !side;
if (node->children[side]->contents != CONTENTS_SOLID if (node->children[side]->contents != CONTENTS_SOLID
@ -938,28 +901,27 @@ R_DrawWorld (void)
currententity = &ent; currententity = &ent;
glColor3f (1.0, 1.0, 1.0);
memset (lightmap_polys, 0, sizeof (lightmap_polys)); memset (lightmap_polys, 0, sizeof (lightmap_polys));
memset (fullbright_polys, 0, sizeof (fullbright_polys)); memset (fullbright_polys, 0, sizeof (fullbright_polys));
// Be sure to clear the skybox --KB if (gl_sky_clip->int_val) {
R_DrawSky (); sky_chain = 0;
} else {
glDisable (GL_BLEND); // Be sure to clear the skybox --KB
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); R_DrawSky ();
}
R_RecursiveWorldNode (cl.worldmodel->nodes); R_RecursiveWorldNode (cl.worldmodel->nodes);
DrawTextureChains (); DrawTextureChains ();
if (gl_texsort->int_val) if (!gl_mtex_active)
R_BlendLightmaps (); R_BlendLightmaps ();
if (gl_fb_bmodels->int_val) if (gl_fb_bmodels->int_val)
R_RenderFullbrights (); R_RenderFullbrights ();
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); if (gl_sky_clip->int_val)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); R_DrawSkyChain (sky_chain);
glEnable (GL_BLEND);
} }
@ -974,9 +936,6 @@ R_MarkLeaves (void)
if (r_oldviewleaf == r_viewleaf && !r_novis->int_val) if (r_oldviewleaf == r_viewleaf && !r_novis->int_val)
return; return;
if (mirror)
return;
r_visframecount++; r_visframecount++;
r_oldviewleaf = r_viewleaf; r_oldviewleaf = r_viewleaf;
@ -1037,7 +996,7 @@ AllocBlock (int w, int h, int *x, int *y)
// LordHavoc: allocate lightmaps only as needed // LordHavoc: allocate lightmaps only as needed
if (!lightmaps[texnum]) if (!lightmaps[texnum])
lightmaps[texnum] = calloc (BLOCK_WIDTH * BLOCK_HEIGHT, 3); lightmaps[texnum] = calloc (BLOCK_WIDTH * BLOCK_HEIGHT, lightmap_bytes); // DESPAIR: was 3, not lightmap_bytes
for (i = 0; i < w; i++) for (i = 0; i < w; i++)
allocated[texnum][*x + i] = best + h; allocated[texnum][*x + i] = best + h;
@ -1065,18 +1024,14 @@ BuildSurfaceDisplayList (msurface_t *fa)
float s, t; float s, t;
glpoly_t *poly; glpoly_t *poly;
// reconstruct the polygon // reconstruct the polygon
pedges = currentmodel->edges; pedges = currentmodel->edges;
lnumverts = fa->numedges; lnumverts = fa->numedges;
vertpage = 0; vertpage = 0;
//
// draw texture // draw texture
// poly = Hunk_Alloc (sizeof (glpoly_t) + (lnumverts - 4) *
poly = VERTEXSIZE * sizeof (float));
Hunk_Alloc (sizeof (glpoly_t) +
(lnumverts - 4) * VERTEXSIZE * sizeof (float));
poly->next = fa->polys; poly->next = fa->polys;
poly->flags = fa->flags; poly->flags = fa->flags;
fa->polys = poly; fa->polys = poly;
@ -1102,9 +1057,7 @@ BuildSurfaceDisplayList (msurface_t *fa)
poly->verts[i][3] = s; poly->verts[i][3] = s;
poly->verts[i][4] = t; poly->verts[i][4] = t;
//
// lightmap texture coordinates // lightmap texture coordinates
//
s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3]; s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
s -= fa->texturemins[0]; s -= fa->texturemins[0];
s += fa->light_s * 16; s += fa->light_s * 16;
@ -1121,9 +1074,7 @@ BuildSurfaceDisplayList (msurface_t *fa)
poly->verts[i][6] = t; poly->verts[i][6] = t;
} }
//
// remove co-linear points - Ed // remove co-linear points - Ed
//
if (!gl_keeptjunctions->int_val && !(fa->flags & SURF_UNDERWATER)) { if (!gl_keeptjunctions->int_val && !(fa->flags & SURF_UNDERWATER)) {
for (i = 0; i < lnumverts; ++i) { for (i = 0; i < lnumverts; ++i) {
vec3_t v1, v2; vec3_t v1, v2;
@ -1176,9 +1127,8 @@ GL_CreateSurfaceLightmap (msurface_t *surf)
surf->lightmaptexturenum = surf->lightmaptexturenum =
AllocBlock (smax, tmax, &surf->light_s, &surf->light_t); AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
base = base = lightmaps[surf->lightmaptexturenum] +
lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
surf->light_s) * lightmap_bytes;
R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes); R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes);
} }
@ -1186,8 +1136,7 @@ GL_CreateSurfaceLightmap (msurface_t *surf)
/* /*
GL_BuildLightmaps GL_BuildLightmaps
Builds the lightmap texture Builds the lightmap texture with all the surfaces from all brush models
with all the surfaces from all brush models
*/ */
void void
GL_BuildLightmaps (void) GL_BuildLightmaps (void)
@ -1204,12 +1153,20 @@ GL_BuildLightmaps (void)
texture_extension_number += MAX_LIGHTMAPS; texture_extension_number += MAX_LIGHTMAPS;
} }
if (gl_colorlights->int_val) { switch (gl_lightmap_components->int_val) {
gl_lightmap_format = GL_RGB; case 1:
lightmap_bytes = 3;
} else {
gl_lightmap_format = GL_LUMINANCE; gl_lightmap_format = GL_LUMINANCE;
lightmap_bytes = 1; lightmap_bytes = 1;
break;
case 3:
gl_lightmap_format = GL_RGB;
lightmap_bytes = 3;
break;
case 4:
default:
gl_lightmap_format = GL_RGBA;
lightmap_bytes = 4;
break;
} }
for (j = 1; j < MAX_MODELS; j++) { for (j = 1; j < MAX_MODELS; j++) {
@ -1223,19 +1180,17 @@ GL_BuildLightmaps (void)
for (i = 0; i < m->numsurfaces; i++) { for (i = 0; i < m->numsurfaces; i++) {
if (m->surfaces[i].flags & SURF_DRAWTURB) if (m->surfaces[i].flags & SURF_DRAWTURB)
continue; continue;
if (m->surfaces[i].flags & SURF_DRAWSKY) if (gl_sky_divide->int_val && (m->surfaces[i].flags & SURF_DRAWSKY))
continue; continue;
GL_CreateSurfaceLightmap (m->surfaces + i); GL_CreateSurfaceLightmap (m->surfaces + i);
BuildSurfaceDisplayList (m->surfaces + i); BuildSurfaceDisplayList (m->surfaces + i);
} }
} }
if (!gl_texsort->int_val) if (gl_mtex_active)
qglSelectTexture (gl_mtex_enum + 1); qglActiveTexture (gl_mtex_enum + 1);
//
// upload all lightmaps that were filled // upload all lightmaps that were filled
//
for (i = 0; i < MAX_LIGHTMAPS; i++) { for (i = 0; i < MAX_LIGHTMAPS; i++) {
if (!allocated[i][0]) if (!allocated[i][0])
break; // no more used break; // no more used
@ -1252,6 +1207,6 @@ GL_BuildLightmaps (void)
GL_UNSIGNED_BYTE, lightmaps[i]); GL_UNSIGNED_BYTE, lightmaps[i]);
} }
if (!gl_texsort->int_val) if (gl_mtex_active)
qglSelectTexture (gl_mtex_enum + 0); qglActiveTexture (gl_mtex_enum + 0);
} }

View file

@ -15,15 +15,16 @@ cvar_t *d_subdiv16;
cvar_t *gl_affinemodels; cvar_t *gl_affinemodels;
cvar_t *gl_clear; cvar_t *gl_clear;
cvar_t *gl_colorlights;
cvar_t *gl_conalpha; cvar_t *gl_conalpha;
cvar_t *gl_conspin; cvar_t *gl_conspin;
cvar_t *gl_constretch; cvar_t *gl_constretch;
cvar_t *gl_cull; cvar_t *gl_cull; // FIXME
cvar_t *gl_dlight_lightmap;
cvar_t *gl_dlight_polyblend;
cvar_t *gl_dlight_smooth;
cvar_t *gl_fb_bmodels; cvar_t *gl_fb_bmodels;
cvar_t *gl_fb_models; cvar_t *gl_fb_models;
cvar_t *gl_fires; cvar_t *gl_fires;
cvar_t *gl_flashblend;
cvar_t *gl_keeptjunctions; cvar_t *gl_keeptjunctions;
cvar_t *gl_lightmap_components; cvar_t *gl_lightmap_components;
cvar_t *gl_lightmode; cvar_t *gl_lightmode;
@ -31,10 +32,11 @@ cvar_t *gl_max_size;
cvar_t *gl_nocolors; cvar_t *gl_nocolors;
cvar_t *gl_picmip; cvar_t *gl_picmip;
cvar_t *gl_playermip; cvar_t *gl_playermip;
cvar_t *gl_polyblend; cvar_t *gl_polyblend; // FIXME
cvar_t *gl_reporttjunctions; cvar_t *gl_reporttjunctions;
cvar_t *gl_sky_clip;
cvar_t *gl_skymultipass; cvar_t *gl_skymultipass;
cvar_t *gl_smoothmodels; cvar_t *gl_smoothmodels; // FIXME
cvar_t *gl_texsort; cvar_t *gl_texsort;
cvar_t *gl_triplebuffer; cvar_t *gl_triplebuffer;
@ -102,41 +104,77 @@ void
R_Init_Cvars (void) R_Init_Cvars (void)
{ {
cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, NULL, "Sets the position of the crosshair on the X-axis"); cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, NULL,
cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, NULL, "Sets the position of the crosshair on the X-axis."); "Sets the position of the crosshair on the X-axis");
cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL, "Sets the position of the crosshair on the Y-axis"); cl_crossx = Cvar_Get ("cl_crossx", "0", CVAR_ARCHIVE, NULL,
cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL, "Sets the position of the crosshair on the Y-axis."); "Sets the position of the crosshair on the X-axis.");
cl_verstring = Cvar_Get ("cl_verstring", PROGRAM " " VERSION, CVAR_NONE, NULL, "Client version string"); cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL,
crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, NULL, "Crosshair type. 0 off, 1 old without color, 2 new with colors"); "Sets the position of the crosshair on the Y-axis");
crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, NULL, "Crosshair type. 0 off, 1 old, 2 new with color"); cl_crossy = Cvar_Get ("cl_crossy", "0", CVAR_ARCHIVE, NULL,
crosshaircolor = Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, NULL, "Color of the new crosshair"); "Sets the position of the crosshair on the Y-axis.");
crosshaircolor = Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, NULL, "Crosshair 2's color"); cl_verstring = Cvar_Get ("cl_verstring", PROGRAM " " VERSION, CVAR_NONE,
NULL, "Client version string");
d_mipcap = Cvar_Get ("d_mipcap", "0", CVAR_NONE, NULL, "None"); crosshair =
d_mipscale = Cvar_Get ("d_mipscale", "1", CVAR_NONE, NULL, "None"); Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, NULL,
d_subdiv16 = Cvar_Get ("d_subdiv16", "1", CVAR_NONE, NULL, "None"); "Crosshair type. 0 off, 1 old without color, 2 new with colors");
crosshaircolor = Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, NULL,
gl_affinemodels = Cvar_Get ("gl_affinemodels", "0", CVAR_NONE, NULL, "None"); "Color of the new crosshair");
gl_clear = Cvar_Get ("gl_clear", "0", CVAR_NONE, NULL, "None"); d_mipcap = Cvar_Get ("d_mipcap", "0", CVAR_NONE, NULL,
gl_colorlights = Cvar_Get ("gl_colorlights", "1", CVAR_ROM, NULL, "Whether to use RGB lightmaps or not"); "Detail level. 0 is highest, 3 is lowest.");
gl_conalpha = Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE, NULL, "alpha value for the console background"); d_mipscale =
gl_conspin = Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE, NULL, "speed at which the console spins"); Cvar_Get ("d_mipscale", "1", CVAR_NONE, NULL,
gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, NULL, "whether slide the console or stretch it"); "Detail level of objects. 0 is highest, 3 is lowest");
d_subdiv16 = Cvar_Get ("d_subdiv16", "1", CVAR_NONE, NULL,
"Set to enable extreme perspective correction");
gl_affinemodels =
Cvar_Get ("gl_affinemodels", "0", CVAR_NONE, NULL,
"Makes texture rendering quality better if set to 1");
gl_clear = Cvar_Get ("gl_clear", "0", CVAR_NONE, NULL,
"Set to 1 to make background black. Useful for removing HOM effect");
gl_conalpha = Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE, NULL,
"alpha value for the console background");
gl_conspin = Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE, NULL,
"speed at which the console spins");
gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, NULL,
"whether slide the console or stretch it");
gl_cull = Cvar_Get ("gl_cull", "1", CVAR_NONE, NULL, "None"); gl_cull = Cvar_Get ("gl_cull", "1", CVAR_NONE, NULL, "None");
gl_fb_bmodels = Cvar_Get ("gl_fb_bmodels", "1", CVAR_ARCHIVE, NULL, "Toggles fullbright color support for bmodels"); gl_dlight_lightmap =
gl_fb_models = Cvar_Get ("gl_fb_models", "1", CVAR_ARCHIVE, NULL, "Toggles fullbright color support for models.. " "This is very handy, but costs me 2 FPS.. (=:]"); Cvar_Get ("gl_dlight_lightmap", "1", CVAR_ARCHIVE, NULL,
gl_fires = Cvar_Get ("gl_fires", "0", CVAR_ARCHIVE, NULL, "Toggles lavaball and rocket fireballs"); "Set to 1 for high quality dynamic lighting.");
gl_flashblend = Cvar_Get ("gl_flashblend", "0", CVAR_NONE, NULL, "None"); gl_dlight_polyblend =
Cvar_Get ("gl_dlight_polyblend", "0", CVAR_ARCHIVE, NULL,
"Set to 1 to use a dynamic light effect faster on GL");
gl_dlight_smooth =
Cvar_Get ("gl_dlight_smooth", "1", CVAR_ARCHIVE, NULL,
"Smooth dynamic vertex lighting");
gl_fb_bmodels = Cvar_Get ("gl_fb_bmodels", "1", CVAR_ARCHIVE, NULL,
"Toggles fullbright color support for bmodels");
gl_fb_models = Cvar_Get ("gl_fb_models", "1", CVAR_ARCHIVE, NULL,
"Toggles fullbright color support for models.. "
"This is very handy, but costs me 2 FPS.. (=:]");
gl_fires = Cvar_Get ("gl_fires", "0", CVAR_ARCHIVE, NULL,
"Toggles lavaball and rocket fireballs");
gl_keeptjunctions = Cvar_Get ("gl_keeptjunctions", "1", CVAR_NONE, NULL, "None"); gl_keeptjunctions = Cvar_Get ("gl_keeptjunctions", "1", CVAR_NONE, NULL, "None");
gl_lightmap_components = Cvar_Get ("gl_lightmap_components", "4", CVAR_ROM, NULL, "Lightmap texture components. 1 is greyscale, 3 is RGB, 4 is RGBA."); gl_lightmap_components =
gl_lightmode = Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE, gl_lightmode_callback, "Lighting mode (0 = GLQuake style, 1 = new style)"); Cvar_Get ("gl_lightmap_components", "4", CVAR_ROM, NULL,
gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, NULL, "Texture dimension"); "Lightmap texture components. 1 is greyscale, 3 is RGB, 4 is RGBA.");
gl_nocolors = Cvar_Get ("gl_nocolors", "0", CVAR_NONE, NULL, "None"); gl_lightmode =
gl_picmip = Cvar_Get ("gl_picmip", "0", CVAR_NONE, NULL, "Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4"); Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE, gl_lightmode_callback,
gl_playermip = Cvar_Get ("gl_playermip", "0", CVAR_NONE, NULL, "None"); "Lighting mode (0 = GLQuake style, 1 = new style)");
gl_polyblend = Cvar_Get ("gl_polyblend", "1", CVAR_NONE, NULL, "None"); gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, NULL,
"Texture dimension");
gl_nocolors = Cvar_Get ("gl_nocolors", "0", CVAR_NONE, NULL,
"Set to 1, turns off all player colors");
gl_picmip = Cvar_Get ("gl_picmip", "0", CVAR_NONE, NULL,
"Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4");
gl_playermip = Cvar_Get ("gl_playermip", "0", CVAR_NONE, NULL,
"Detail of player skins. 0 best, 4 worst.");
gl_reporttjunctions = Cvar_Get ("gl_reporttjunctions", "0", CVAR_NONE, NULL, "None"); gl_reporttjunctions = Cvar_Get ("gl_reporttjunctions", "0", CVAR_NONE, NULL, "None");
gl_skymultipass = Cvar_Get ("gl_skymultipass", "1", CVAR_NONE, NULL, "controls wether the skydome is single or double pass"); gl_sky_clip =
Cvar_Get ("gl_sky_clip", "0", CVAR_ARCHIVE, NULL,
"controls whether sky is drawn first (0) or later (1)");
gl_skymultipass = Cvar_Get ("gl_skymultipass", "1", CVAR_NONE, NULL,
"controls wether the skydome is single or double pass");
gl_smoothmodels = Cvar_Get ("gl_smoothmodels", "1", CVAR_NONE, NULL, "None"); gl_smoothmodels = Cvar_Get ("gl_smoothmodels", "1", CVAR_NONE, NULL, "None");
gl_texsort = Cvar_Get ("gl_texsort", "1", CVAR_NONE, NULL, "None"); gl_texsort = Cvar_Get ("gl_texsort", "1", CVAR_NONE, NULL, "None");
gl_triplebuffer = Cvar_Get ("gl_triplebuffer", "1", CVAR_ARCHIVE, NULL, "Set to 1 by default. Fixes status bar flicker on some hardware"); gl_triplebuffer = Cvar_Get ("gl_triplebuffer", "1", CVAR_ARCHIVE, NULL, "Set to 1 by default. Fixes status bar flicker on some hardware");

View file

@ -76,9 +76,7 @@ qboolean envmap; // true during envmap command capture
int playertextures; // up to 16 color translated skins int playertextures; // up to 16 color translated skins
int player_fb_textures; // up to 128 skin fullbright maps int player_fb_textures; // up to 128 skin fullbright maps
//
// view origin // view origin
//
vec3_t vup; vec3_t vup;
vec3_t vpn; vec3_t vpn;
vec3_t vright; vec3_t vright;
@ -87,16 +85,13 @@ vec3_t r_origin;
float r_world_matrix[16]; float r_world_matrix[16];
float r_base_world_matrix[16]; float r_base_world_matrix[16];
//
// screen size info // screen size info
//
refdef_t r_refdef; refdef_t r_refdef;
mleaf_t *r_viewleaf, *r_oldviewleaf; mleaf_t *r_viewleaf, *r_oldviewleaf;
int d_lightstylevalue[256]; // 8.8 fraction of base light value int d_lightstylevalue[256]; // 8.8 fraction of base light value
vec3_t shadecolor; // Ender (Extend) Colormod vec3_t shadecolor; // Ender (Extend) Colormod
float modelalpha; // Ender (EXtend) Alpha float modelalpha; // Ender (EXtend) Alpha
@ -107,29 +102,13 @@ extern cvar_t *scr_fov;
extern byte gammatable[256]; extern byte gammatable[256];
extern qboolean lighthalf; extern qboolean lighthalf;
// LordHavoc: place for gl_rmain setup code // LordHavoc: place for gl_rmain setup code
void void
glrmain_init (void) glrmain_init (void)
{ {
} }
/*
R_CullBox
Returns true if the box is completely outside the frustum
*/
/*
qboolean R_CullBox (vec3_t mins, vec3_t maxs)
{
int i;
for (i=0 ; i<4 ; i++)
if (BoxOnPlaneSide (mins, maxs, &frustum[i]) == 2)
return true;
return false;
}
*/
void void
R_RotateForEntity (entity_t *e) R_RotateForEntity (entity_t *e)
@ -257,18 +236,14 @@ float shadelight;
// precalculated dot products for quantized angles // precalculated dot products for quantized angles
#define SHADEDOT_QUANT 16 #define SHADEDOT_QUANT 16
float r_avertexnormal_dots[SHADEDOT_QUANT][256] = float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
#include "anorm_dots.h" #include "anorm_dots.h"
; ;
float *shadedots = r_avertexnormal_dots[0]; float *shadedots = r_avertexnormal_dots[0];
int lastposenum, lastposenum0; int lastposenum, lastposenum0;
/*
GL_DrawAliasFrame
Standard model drawing
*/
static void static void
GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb) GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
{ {
@ -286,7 +261,7 @@ GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
if (modelalpha != 1.0) if (modelalpha != 1.0)
glDepthMask (GL_FALSE); glDepthMask (GL_FALSE);
if (fb) { // don't do this in the loop, it doesn't change if (fb) {
if (lighthalf) if (lighthalf)
glColor4f (0.5, 0.5, 0.5, modelalpha); glColor4f (0.5, 0.5, 0.5, modelalpha);
else else
@ -406,13 +381,14 @@ GL_DrawAliasBlendedFrame (aliashdr_t *paliashdr, int pose1, int pose2, float ble
} }
extern vec3_t lightspot;
/* /*
GL_DrawAliasShadow GL_DrawAliasShadow
Standard shadow drawing Standard shadow drawing
*/ */
extern vec3_t lightspot;
static void static void
GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum) GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
{ {
@ -446,9 +422,15 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
order += 2; order += 2;
// normals and vertexes come from the frame list // normals and vertexes come from the frame list
point[0] = verts->v[0] * paliashdr->mdl.scale[0] + paliashdr->mdl.scale_origin[0]; point[0] =
point[1] = verts->v[1] * paliashdr->mdl.scale[1] + paliashdr->mdl.scale_origin[1]; verts->v[0] * paliashdr->mdl.scale[0] +
point[2] = verts->v[2] * paliashdr->mdl.scale[2] + paliashdr->mdl.scale_origin[2]; paliashdr->mdl.scale_origin[0];
point[1] =
verts->v[1] * paliashdr->mdl.scale[1] +
paliashdr->mdl.scale_origin[1];
point[2] =
verts->v[2] * paliashdr->mdl.scale[2] +
paliashdr->mdl.scale_origin[2];
point[0] -= shadevector[0] * (point[2] + lheight); point[0] -= shadevector[0] * (point[2] + lheight);
point[1] -= shadevector[1] * (point[2] + lheight); point[1] -= shadevector[1] * (point[2] + lheight);
@ -463,6 +445,7 @@ GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
} }
} }
/* /*
GL_DrawAliasBlendedShadow GL_DrawAliasBlendedShadow
@ -572,7 +555,7 @@ R_SetupAliasBlendedFrame (int frame, aliashdr_t *paliashdr, entity_t *e, qboolea
pose += (int) (cl.time / e->frame_interval) % numposes; pose += (int) (cl.time / e->frame_interval) % numposes;
} else { } else {
/* /*
One tenth of a second is a good for most Quake animations. If the One tenth of a second is good for most Quake animations. If the
nextthink is longer then the animation is usually meant to pause nextthink is longer then the animation is usually meant to pause
(e.g. check out the shambler magic animation in shambler.qc). If (e.g. check out the shambler magic animation in shambler.qc). If
its shorter then things will still be smoothed partly, and the its shorter then things will still be smoothed partly, and the
@ -594,7 +577,6 @@ R_SetupAliasBlendedFrame (int frame, aliashdr_t *paliashdr, entity_t *e, qboolea
} else { } else {
blend = (realtime - e->frame_start_time) / e->frame_interval; blend = (realtime - e->frame_start_time) / e->frame_interval;
} }
// Con_DPrintf ("numposes: %d, poses: %d %d\n", numposes, e->pose1, e->pose2);
// wierd things start happening if blend passes 1 // wierd things start happening if blend passes 1
if (cl.paused || blend > 1) if (cl.paused || blend > 1)
@ -799,7 +781,6 @@ R_DrawAliasModel (entity_t *e)
} }
} }
//==================================================================================
/* /*
R_ShowNearestLoc R_ShowNearestLoc
@ -1046,9 +1027,7 @@ R_SetupGL (void)
glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix); glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
//
// set drawing parms // set drawing parms
//
glEnable (GL_CULL_FACE); glEnable (GL_CULL_FACE);
glDisable (GL_ALPHA_TEST); glDisable (GL_ALPHA_TEST);
glAlphaFunc (GL_GREATER, 0.5); glAlphaFunc (GL_GREATER, 0.5);

View file

@ -54,19 +54,16 @@
varray_t2f_c4f_v3f_t varray[MAX_VARRAY_VERTS]; varray_t2f_c4f_v3f_t varray[MAX_VARRAY_VERTS];
qboolean VID_Is8bit (void); qboolean VID_Is8bit (void);
void R_InitBubble (void); qboolean allowskybox; // allow skyboxes? --KB
void R_InitBubble (void);
extern cvar_t *gl_lerp_anim; extern cvar_t *gl_lerp_anim;
extern cvar_t *r_netgraph; extern cvar_t *r_netgraph;
extern void GDT_Init (); extern void GDT_Init ();
qboolean allowskybox; // allow skyboxes? --KB
/*
R_Textures_Init
*/
void void
R_Textures_Init (void) R_Textures_Init (void)
{ {
@ -98,6 +95,7 @@ R_Textures_Init (void)
} }
} }
/* /*
R_Envmap_f R_Envmap_f
@ -163,9 +161,7 @@ R_Envmap_f (void)
GL_EndRendering (); GL_EndRendering ();
} }
/*
R_LoadSky_f
*/
void void
R_LoadSky_f (void) R_LoadSky_f (void)
{ {
@ -178,18 +174,17 @@ R_LoadSky_f (void)
} }
/*
R_Init
*/
void void
R_Init (void) R_Init (void)
{ {
allowskybox = false; // server will decide if this is allowskybox = false; // server will decide if this is
// allowed --KB // allowed --KB
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f, "Tests the current refresh rate for the current location"); Cmd_AddCommand ("timerefresh", R_TimeRefresh_f,
Cmd_AddCommand ("envmap", R_Envmap_f, "FIXME: What on earth does this do? No Description"); "Tests the current refresh rate for the current location");
Cmd_AddCommand ("pointfile", R_ReadPointFile_f, "Load a pointfile to determine map leaks"); Cmd_AddCommand ("envmap", R_Envmap_f, "No Description");
Cmd_AddCommand ("pointfile", R_ReadPointFile_f,
"Load a pointfile to determine map leaks");
Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox"); Cmd_AddCommand ("loadsky", R_LoadSky_f, "Load a skybox");
R_InitBubble (); R_InitBubble ();
@ -214,9 +209,7 @@ R_Init (void)
glVertexPointer (3, GL_FLOAT, sizeof(varray[0]), varray[0].vertex); glVertexPointer (3, GL_FLOAT, sizeof(varray[0]), varray[0].vertex);
} }
/*
R_NewMap
*/
void void
R_NewMap (void) R_NewMap (void)
{ {
@ -229,7 +222,7 @@ R_NewMap (void)
memset (&r_worldentity, 0, sizeof (r_worldentity)); memset (&r_worldentity, 0, sizeof (r_worldentity));
r_worldentity.model = cl.worldmodel; r_worldentity.model = cl.worldmodel;
// clear out efrags in case the level hasn't been reloaded // clear out efrags in case the level hasn't been reloaded
for (i = 0; i < cl.worldmodel->numleafs; i++) for (i = 0; i < cl.worldmodel->numleafs; i++)
cl.worldmodel->leafs[i].efrags = NULL; cl.worldmodel->leafs[i].efrags = NULL;
@ -267,7 +260,6 @@ R_TimeRefresh_f (void)
int i; int i;
double start, stop, time; double start, stop, time;
// glDrawBuffer (GL_FRONT);
glFinish (); glFinish ();
GL_EndRendering (); GL_EndRendering ();
@ -280,13 +272,10 @@ R_TimeRefresh_f (void)
GL_EndRendering (); GL_EndRendering ();
} }
// glFinish ();
stop = Sys_DoubleTime (); stop = Sys_DoubleTime ();
time = stop - start; time = stop - start;
Con_Printf ("%f seconds (%f fps)\n", time, 128 / time); Con_Printf ("%f seconds (%f fps)\n", time, 128 / time);
// glDrawBuffer (GL_BACK);
// GL_EndRendering ();
GL_BeginRendering (&glx, &gly, &glwidth, &glheight); GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
} }

View file

@ -49,12 +49,13 @@
#include "r_local.h" #include "r_local.h"
#include "r_shared.h" #include "r_shared.h"
qboolean r_cache_thrash; qboolean r_cache_thrash;
extern double realtime; extern double realtime;
int skytexturenum; int skytexturenum;
extern vec3_t shadecolor; // Ender (Extend) Colormod extern vec3_t shadecolor; // Ender (Extend) Colormod
int lightmap_bytes; // 1, 3, or 4 int lightmap_bytes; // 1, 3, or 4
int lightmap_textures; int lightmap_textures;
@ -168,14 +169,16 @@ R_AddDynamicLights (msurface_t *surf)
impact[i] = impact[i] =
cl_dlights[lnum].origin[i] - surf->plane->normal[i] * dist; cl_dlights[lnum].origin[i] - surf->plane->normal[i] * dist;
i = f = DotProduct (impact, surf->texinfo->vecs[0]) + surf->texinfo->vecs[0][3] - surf->texturemins[0]; i = f = DotProduct (impact, surf->texinfo->vecs[0]) +
surf->texinfo->vecs[0][3] - surf->texturemins[0];
// reduce calculations // reduce calculations
t = dist * dist; t = dist * dist;
for (s = 0; s < smax; s++, i -= 16) for (s = 0; s < smax; s++, i -= 16)
sdtable[s] = i * i + t; sdtable[s] = i * i + t;
i = f = DotProduct (impact, surf->texinfo->vecs[1]) + surf->texinfo->vecs[1][3] - surf->texturemins[1]; i = f = DotProduct (impact, surf->texinfo->vecs[1]) +
surf->texinfo->vecs[1][3] - surf->texturemins[1];
// for comparisons to minimum acceptable light // for comparisons to minimum acceptable light
maxdist = (int) ((cl_dlights[lnum].radius * cl_dlights[lnum].radius) * 0.75); maxdist = (int) ((cl_dlights[lnum].radius * cl_dlights[lnum].radius) * 0.75);
@ -268,9 +271,9 @@ R_BuildLightMap (msurface_t *surf, byte * dest, int stride)
bl = blocklights; bl = blocklights;
if (gl_mtex_active && !lighthalf) { if (gl_mtex_active && !lighthalf) {
shift = 7; // 0-1 lightmap range. shift = 7; // 0-1 lightmap range.
} else { } else {
shift = 8; // 0-2 lightmap range. shift = 8; // 0-2 lightmap range.
} }
switch (lightmap_bytes) { switch (lightmap_bytes) {
@ -360,11 +363,10 @@ extern float speedscale; // for top sky and bottom sky
void void
GL_UploadLightmap (int i, int x, int y, int w, int h) GL_UploadLightmap (int i, int x, int y, int w, int h)
{ {
/* /* glTexSubImage2D (GL_TEXTURE_2D, 0, 0, y, BLOCK_WIDTH, h, gl_lightmap_format,
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, y, BLOCK_WIDTH, h, gl_lightmap_format,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
lightmaps[i] + (y * BLOCK_WIDTH) * lightmap_bytes); lightmaps[i] + (y * BLOCK_WIDTH) * lightmap_bytes);
*/ */
glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH, glTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes, BLOCK_WIDTH,
BLOCK_HEIGHT, 0, gl_lightmap_format, BLOCK_HEIGHT, 0, gl_lightmap_format,
GL_UNSIGNED_BYTE, lightmaps[i]); GL_UNSIGNED_BYTE, lightmaps[i]);
@ -407,7 +409,7 @@ R_DrawMultitexturePoly (msurface_t *s)
if (d_lightstylevalue[s->styles[maps]] != s->cached_light[maps]) if (d_lightstylevalue[s->styles[maps]] != s->cached_light[maps])
goto dynamic; goto dynamic;
if ((s->dlightframe = r_framecount) || s->cached_dlight) { if ((s->dlightframe == r_framecount) || s->cached_dlight) {
dynamic: dynamic:
R_BuildLightMap (s, R_BuildLightMap (s,
lightmaps[s->lightmaptexturenum] + lightmaps[s->lightmaptexturenum] +
@ -448,7 +450,7 @@ R_BlendLightmaps (void)
glpoly_t *p; glpoly_t *p;
float *v; float *v;
glDepthMask (GL_FALSE); // don't bother writing Z glDepthMask (GL_FALSE); // don't bother writing Z
if (lighthalf) if (lighthalf)
glBlendFunc (GL_ZERO, GL_SRC_COLOR); glBlendFunc (GL_ZERO, GL_SRC_COLOR);
@ -484,7 +486,7 @@ R_BlendLightmaps (void)
glColor3ubv (lighthalf_v); glColor3ubv (lighthalf_v);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask (GL_TRUE); // back to normal Z buffering glDepthMask (GL_TRUE); // back to normal Z buffering
} }
@ -574,9 +576,8 @@ R_RenderBrushPoly (msurface_t *fa)
if ((theRect->h + theRect->t) < (fa->light_t + tmax)) if ((theRect->h + theRect->t) < (fa->light_t + tmax))
theRect->h = (fa->light_t - theRect->t) + tmax; theRect->h = (fa->light_t - theRect->t) + tmax;
base = base =
lightmaps[fa->lightmaptexturenum] + (fa->light_t * BLOCK_WIDTH + lightmaps[fa->lightmaptexturenum] +
fa->light_s) * (fa->light_t * BLOCK_WIDTH + fa->light_s) * lightmap_bytes;
lightmap_bytes;
R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes); R_BuildLightMap (fa, base, BLOCK_WIDTH * lightmap_bytes);
} }
} }
@ -616,7 +617,6 @@ R_DrawWaterSurfaces (void)
return; return;
// go back to the world matrix // go back to the world matrix
glLoadMatrixf (r_world_matrix); glLoadMatrixf (r_world_matrix);
if (r_wateralpha->value < 1.0) { if (r_wateralpha->value < 1.0) {
@ -739,6 +739,11 @@ R_DrawBrushModel (entity_t *e)
// draw texture // draw texture
for (i = 0; i < clmodel->nummodelsurfaces; i++, psurf++) { for (i = 0; i < clmodel->nummodelsurfaces; i++, psurf++) {
/* FIXME: Not in qw?
if (psurf->flags & SURF_DRAWSKY)
return;
*/
// find which side of the node we are on // find which side of the node we are on
pplane = psurf->plane; pplane = psurf->plane;
@ -747,7 +752,6 @@ R_DrawBrushModel (entity_t *e)
// draw the polygon // draw the polygon
if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) || if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
(!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) { (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON))) {
if (psurf->flags & SURF_DRAWTURB) { if (psurf->flags & SURF_DRAWTURB) {
GL_WaterSurface (psurf); GL_WaterSurface (psurf);
} else if (psurf->flags & SURF_DRAWSKY) { } else if (psurf->flags & SURF_DRAWSKY) {
@ -789,9 +793,8 @@ R_RecursiveWorldNode (mnode_t *node)
mleaf_t *pleaf; mleaf_t *pleaf;
double dot; double dot;
if (node->contents == CONTENTS_SOLID) // solid if (node->contents == CONTENTS_SOLID)
return; return;
if (node->visframe != r_visframecount) if (node->visframe != r_visframecount)
return; return;
if (R_CullBox (node->minmaxs, node->minmaxs + 3)) if (R_CullBox (node->minmaxs, node->minmaxs + 3))
@ -860,7 +863,6 @@ R_RecursiveWorldNode (mnode_t *node)
if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK)) if ((dot < 0) ^ !!(surf->flags & SURF_PLANEBACK))
continue; // wrong side continue; // wrong side
if (surf->flags & SURF_DRAWTURB) { if (surf->flags & SURF_DRAWTURB) {
surf->texturechain = waterchain; surf->texturechain = waterchain;
waterchain = surf; waterchain = surf;
@ -958,7 +960,7 @@ R_MarkLeaves (void)
/* /*
LIGHTMAP ALLOCATION LIGHTMAP ALLOCATION
*/ */
@ -1009,7 +1011,6 @@ AllocBlock (int w, int h, int *x, int *y)
mvertex_t *r_pcurrentvertbase; mvertex_t *r_pcurrentvertbase;
model_t *currentmodel; model_t *currentmodel;
int nColinElim; int nColinElim;
@ -1029,7 +1030,8 @@ BuildSurfaceDisplayList (msurface_t *fa)
vertpage = 0; vertpage = 0;
// draw texture // draw texture
poly = Hunk_Alloc (sizeof (glpoly_t) + (lnumverts - 4) * VERTEXSIZE * sizeof (float)); poly = Hunk_Alloc (sizeof (glpoly_t) + (lnumverts - 4) *
VERTEXSIZE * sizeof (float));
poly->next = fa->polys; poly->next = fa->polys;
poly->flags = fa->flags; poly->flags = fa->flags;
fa->polys = poly; fa->polys = poly;
@ -1108,7 +1110,6 @@ BuildSurfaceDisplayList (msurface_t *fa)
} }
} }
poly->numverts = lnumverts; poly->numverts = lnumverts;
} }
@ -1124,8 +1125,10 @@ GL_CreateSurfaceLightmap (msurface_t *surf)
smax = (surf->extents[0] >> 4) + 1; smax = (surf->extents[0] >> 4) + 1;
tmax = (surf->extents[1] >> 4) + 1; tmax = (surf->extents[1] >> 4) + 1;
surf->lightmaptexturenum = AllocBlock (smax, tmax, &surf->light_s, &surf->light_t); surf->lightmaptexturenum =
base = lightmaps[surf->lightmaptexturenum] + (surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes; AllocBlock (smax, tmax, &surf->light_s, &surf->light_t);
base = lightmaps[surf->lightmaptexturenum] +
(surf->light_t * BLOCK_WIDTH + surf->light_s) * lightmap_bytes;
R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes); R_BuildLightMap (surf, base, BLOCK_WIDTH * lightmap_bytes);
} }

View file

@ -19,8 +19,6 @@ cvar_t *gl_conalpha;
cvar_t *gl_conspin; cvar_t *gl_conspin;
cvar_t *gl_constretch; cvar_t *gl_constretch;
cvar_t *gl_dlight_lightmap; cvar_t *gl_dlight_lightmap;
cvar_t *gl_dlight_lightmap;
cvar_t *gl_dlight_polyblend;
cvar_t *gl_dlight_polyblend; cvar_t *gl_dlight_polyblend;
cvar_t *gl_dlight_smooth; cvar_t *gl_dlight_smooth;
cvar_t *gl_fb_bmodels; cvar_t *gl_fb_bmodels;
@ -44,18 +42,15 @@ cvar_t *r_aliastransbase;
cvar_t *r_ambient; cvar_t *r_ambient;
cvar_t *r_clearcolor; cvar_t *r_clearcolor;
cvar_t *r_drawentities; cvar_t *r_drawentities;
cvar_t *r_drawentities;
cvar_t *r_drawflat; cvar_t *r_drawflat;
cvar_t *r_draworder; cvar_t *r_draworder;
cvar_t *r_drawviewmodel; cvar_t *r_drawviewmodel;
cvar_t *r_drawviewmodel;
cvar_t *r_dspeeds; cvar_t *r_dspeeds;
cvar_t *r_dynamic; cvar_t *r_dynamic;
cvar_t *r_graphheight; cvar_t *r_graphheight;
cvar_t *r_maxedges; cvar_t *r_maxedges;
cvar_t *r_maxsurfs; cvar_t *r_maxsurfs;
cvar_t *r_netgraph; cvar_t *r_netgraph;
cvar_t *r_netgraph;
cvar_t *r_netgraph_alpha; cvar_t *r_netgraph_alpha;
cvar_t *r_netgraph_box; cvar_t *r_netgraph_box;
cvar_t *r_norefresh; cvar_t *r_norefresh;
@ -63,13 +58,11 @@ cvar_t *r_novis;
cvar_t *r_numedges; cvar_t *r_numedges;
cvar_t *r_numsurfs; cvar_t *r_numsurfs;
cvar_t *r_particles; cvar_t *r_particles;
cvar_t *r_particles;
cvar_t *r_reportedgeout; cvar_t *r_reportedgeout;
cvar_t *r_reportsurfout; cvar_t *r_reportsurfout;
cvar_t *r_shadows; cvar_t *r_shadows;
cvar_t *r_skyname; cvar_t *r_skyname;
cvar_t *r_speeds; cvar_t *r_speeds;
cvar_t *r_speeds;
cvar_t *r_timegraph; cvar_t *r_timegraph;
cvar_t *r_wateralpha; cvar_t *r_wateralpha;
cvar_t *r_waterripple; cvar_t *r_waterripple;
@ -118,35 +111,27 @@ R_Init_Cvars (void)
crosshair = crosshair =
Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, NULL, Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, NULL,
"Crosshair type. 0 off, 1 old without color, 2 new with colors"); "Crosshair type. 0 off, 1 old without color, 2 new with colors");
crosshaircolor = crosshaircolor = Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, NULL,
Cvar_Get ("crosshaircolor", "79", CVAR_ARCHIVE, NULL, "Color of the new crosshair");
"Color of the new crosshair"); d_mipcap = Cvar_Get ("d_mipcap", "0", CVAR_NONE, NULL,
"Detail level. 0 is highest, 3 is lowest.");
d_mipcap =
Cvar_Get ("d_mipcap", "0", CVAR_NONE, NULL,
"Detail level. 0 is highest, 3 is lowest.");
d_mipscale = d_mipscale =
Cvar_Get ("d_mipscale", "1", CVAR_NONE, NULL, Cvar_Get ("d_mipscale", "1", CVAR_NONE, NULL,
"Detail level of objects. 0 is highest, 3 is lowest."); "Detail level of objects. 0 is highest, 3 is lowest.");
d_subdiv16 = d_subdiv16 =
Cvar_Get ("d_subdiv16", "1", CVAR_NONE, NULL, Cvar_Get ("d_subdiv16", "1", CVAR_NONE, NULL,
"Set to enable extreme perspective correction"); "Set to enable extreme perspective correction");
gl_affinemodels = gl_affinemodels =
Cvar_Get ("gl_affinemodels", "0", CVAR_ARCHIVE, NULL, Cvar_Get ("gl_affinemodels", "0", CVAR_ARCHIVE, NULL,
"Makes texture rendering quality better if set to 1"); "Makes texture rendering quality better if set to 1");
gl_clear = gl_clear = Cvar_Get ("gl_clear", "0", CVAR_NONE, NULL,
Cvar_Get ("gl_clear", "0", CVAR_NONE, NULL, "Set to 1 to make background black. Useful for removing HOM effect");
"Set to 1 to make background black. Useful for removing HOM effect"); gl_conalpha = Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE, NULL,
gl_conalpha = "alpha value for the console background");
Cvar_Get ("gl_conalpha", "0.6", CVAR_ARCHIVE, NULL, gl_conspin = Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE, NULL,
"alpha value for the console background"); "speed at which the console spins");
gl_conspin = gl_constretch = Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, NULL,
Cvar_Get ("gl_conspin", "0", CVAR_ARCHIVE, NULL, "whether slide the console or stretch it");
"speed at which the console spins");
gl_constretch =
Cvar_Get ("gl_constretch", "0", CVAR_ARCHIVE, NULL,
"whether slide the console or stretch it");
gl_dlight_lightmap = gl_dlight_lightmap =
Cvar_Get ("gl_dlight_lightmap", "1", CVAR_ARCHIVE, NULL, Cvar_Get ("gl_dlight_lightmap", "1", CVAR_ARCHIVE, NULL,
"Set to 1 for high quality dynamic lighting."); "Set to 1 for high quality dynamic lighting.");
@ -177,11 +162,10 @@ R_Init_Cvars (void)
gl_lightmode = gl_lightmode =
Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE, gl_lightmode_callback, Cvar_Get ("gl_lightmode", "1", CVAR_ARCHIVE, gl_lightmode_callback,
"Lighting mode (0 = GLQuake style, 1 = new style)"); "Lighting mode (0 = GLQuake style, 1 = new style)");
gl_max_size = gl_max_size = Cvar_Get ("gl_max_size", "1024", CVAR_NONE, NULL,
Cvar_Get ("gl_max_size", "1024", CVAR_NONE, NULL, "Texture dimension"); "Texture dimension");
gl_nocolors = gl_nocolors = Cvar_Get ("gl_nocolors", "0", CVAR_NONE, NULL,
Cvar_Get ("gl_nocolors", "0", CVAR_NONE, NULL, "Set to 1, turns off all player colors");
"Set to 1, turns off all player colors");
gl_picmip = gl_picmip =
Cvar_Get ("gl_picmip", "0", CVAR_NONE, NULL, Cvar_Get ("gl_picmip", "0", CVAR_NONE, NULL,
"Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4"); "Dimensions of displayed textures. 0 is normal, 1 is half, 2 is 1/4");
@ -194,9 +178,6 @@ R_Init_Cvars (void)
gl_sky_divide = gl_sky_divide =
Cvar_Get ("gl_sky_divide", "1", CVAR_ARCHIVE, NULL, Cvar_Get ("gl_sky_divide", "1", CVAR_ARCHIVE, NULL,
"subdivide sky polys"); "subdivide sky polys");
gl_sky_divide =
Cvar_Get ("gl_sky_divide", "1", CVAR_ARCHIVE, NULL,
"subdivide sky polys");
gl_skymultipass = gl_skymultipass =
Cvar_Get ("gl_skymultipass", "1", CVAR_ARCHIVE, NULL, Cvar_Get ("gl_skymultipass", "1", CVAR_ARCHIVE, NULL,
"controls whether the skydome is single or double pass"); "controls whether the skydome is single or double pass");