2007-06-21 22:00:00 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 1997-2001 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 the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// cl_view.c -- player rendering positioning
|
|
|
|
|
2008-06-09 22:00:00 +02:00
|
|
|
#include "common.h"
|
2007-06-21 22:00:00 +02:00
|
|
|
#include "client.h"
|
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
// refdef ents
|
|
|
|
#define MAX_ENTITIES 4096 // FIXME: wrote dynamic allocator
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
//=============
|
|
|
|
//
|
|
|
|
// development tools for weapons
|
|
|
|
//
|
2008-06-30 22:00:00 +02:00
|
|
|
model_t *gun_model;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
//=============
|
|
|
|
|
|
|
|
cvar_t *crosshair;
|
|
|
|
cvar_t *cl_testparticles;
|
|
|
|
cvar_t *cl_testentities;
|
|
|
|
cvar_t *cl_testlights;
|
|
|
|
cvar_t *cl_testblend;
|
|
|
|
|
|
|
|
cvar_t *cl_stats;
|
|
|
|
|
2008-01-13 22:00:00 +01:00
|
|
|
int r_numdlights;
|
2008-07-17 22:00:00 +02:00
|
|
|
dlight_t r_dlights[MAX_DLIGHTS];
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-01-13 22:00:00 +01:00
|
|
|
int r_numparticles;
|
2007-06-21 22:00:00 +02:00
|
|
|
particle_t r_particles[MAX_PARTICLES];
|
|
|
|
|
|
|
|
lightstyle_t r_lightstyles[MAX_LIGHTSTYLES];
|
|
|
|
|
|
|
|
char cl_weaponmodels[MAX_CLIENTWEAPONMODELS][MAX_QPATH];
|
|
|
|
int num_cl_weaponmodels;
|
|
|
|
|
2007-11-13 22:00:00 +01:00
|
|
|
int entitycmpfnc( const entity_t *a, const entity_t *b )
|
|
|
|
{
|
|
|
|
// all other models are sorted by model then skin
|
2008-06-30 22:00:00 +02:00
|
|
|
return ((int)a->model - (int)b->model);
|
2007-11-13 22:00:00 +01:00
|
|
|
}
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
/*
|
|
|
|
====================
|
|
|
|
V_ClearScene
|
|
|
|
|
|
|
|
Specifies the model that will be used as the world
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
void V_ClearScene (void)
|
|
|
|
{
|
|
|
|
r_numdlights = 0;
|
2008-07-17 22:00:00 +02:00
|
|
|
cls.ref_numents = 0;
|
2007-06-21 22:00:00 +02:00
|
|
|
r_numparticles = 0;
|
|
|
|
}
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
void V_CalcRect( void )
|
|
|
|
|
|
|
|
Sets scr_vrect, the coordinates of the rendered window
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void V_CalcRect( void )
|
|
|
|
{
|
2007-11-18 22:00:00 +01:00
|
|
|
scr_vrect.width = scr_width->integer;
|
2007-11-06 22:00:00 +01:00
|
|
|
scr_vrect.width &= ~7;
|
2007-11-18 22:00:00 +01:00
|
|
|
scr_vrect.height = scr_height->integer;
|
2007-11-06 22:00:00 +01:00
|
|
|
scr_vrect.height &= ~1;
|
|
|
|
scr_vrect.y = scr_vrect.x = 0;
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
V_AddEntity
|
|
|
|
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void V_AddEntity (entity_t *ent)
|
|
|
|
{
|
2008-07-17 22:00:00 +02:00
|
|
|
if( cls.ref_numents >= host.max_edicts )
|
2007-06-21 22:00:00 +02:00
|
|
|
return;
|
2008-07-17 22:00:00 +02:00
|
|
|
cls.ref_entities[cls.ref_numents++] = *ent;
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
V_AddParticle
|
|
|
|
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void V_AddParticle (vec3_t org, int color, float alpha)
|
|
|
|
{
|
|
|
|
particle_t *p;
|
|
|
|
|
|
|
|
if (r_numparticles >= MAX_PARTICLES)
|
|
|
|
return;
|
|
|
|
p = &r_particles[r_numparticles++];
|
|
|
|
VectorCopy (org, p->origin);
|
|
|
|
p->color = color;
|
|
|
|
p->alpha = alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
V_AddLight
|
|
|
|
|
|
|
|
=====================
|
|
|
|
*/
|
|
|
|
void V_AddLight (vec3_t org, float intensity, float r, float g, float b)
|
|
|
|
{
|
|
|
|
dlight_t *dl;
|
|
|
|
|
|
|
|
if (r_numdlights >= MAX_DLIGHTS)
|
|
|
|
return;
|
|
|
|
dl = &r_dlights[r_numdlights++];
|
|
|
|
VectorCopy (org, dl->origin);
|
|
|
|
dl->intensity = intensity;
|
|
|
|
dl->color[0] = r;
|
|
|
|
dl->color[1] = g;
|
|
|
|
dl->color[2] = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=====================
|
|
|
|
V_AddLightStyle
|
|
|
|
|
|
|
|
=====================
|
|
|
|
*/
|
2008-06-14 22:00:00 +02:00
|
|
|
void V_AddLightStyle( int style, float r, float g, float b )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
|
|
|
lightstyle_t *ls;
|
|
|
|
|
|
|
|
if (style < 0 || style > MAX_LIGHTSTYLES)
|
2007-09-10 22:00:00 +02:00
|
|
|
Host_Error("V_AddLightStyle: invalid light style %i\n", style);
|
2007-06-21 22:00:00 +02:00
|
|
|
ls = &r_lightstyles[style];
|
|
|
|
|
|
|
|
ls->white = r+g+b;
|
|
|
|
ls->rgb[0] = r;
|
|
|
|
ls->rgb[1] = g;
|
|
|
|
ls->rgb[2] = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
V_TestParticles
|
|
|
|
|
|
|
|
If cl_testparticles is set, create 4096 particles in the view
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void V_TestParticles (void)
|
|
|
|
{
|
|
|
|
particle_t *p;
|
|
|
|
int i, j;
|
|
|
|
float d, r, u;
|
|
|
|
|
|
|
|
r_numparticles = MAX_PARTICLES;
|
|
|
|
for (i=0 ; i<r_numparticles ; i++)
|
|
|
|
{
|
|
|
|
d = i*0.25;
|
|
|
|
r = 4*((i&7)-3.5);
|
|
|
|
u = 4*(((i>>3)&7)-3.5);
|
|
|
|
p = &r_particles[i];
|
|
|
|
|
|
|
|
for (j=0 ; j<3 ; j++)
|
|
|
|
p->origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j]*d +
|
|
|
|
cl.v_right[j]*r + cl.v_up[j]*u;
|
|
|
|
|
|
|
|
p->color = 8;
|
|
|
|
p->alpha = cl_testparticles->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
V_TestEntities
|
|
|
|
|
|
|
|
If cl_testentities is set, create 32 player models
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void V_TestEntities (void)
|
|
|
|
{
|
2008-07-17 22:00:00 +02:00
|
|
|
int i, j;
|
2007-06-21 22:00:00 +02:00
|
|
|
float f, r;
|
2008-07-17 22:00:00 +02:00
|
|
|
entity_t *ent;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
cls.ref_numents = 32;
|
|
|
|
memset( cls.ref_entities, 0, sizeof(entity_t));
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
for( i = 0; i < cls.ref_numents; i++ )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2008-07-17 22:00:00 +02:00
|
|
|
ent = &cls.ref_entities[i];
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
r = 64 * ((i%4) - 1.5 );
|
2007-06-21 22:00:00 +02:00
|
|
|
f = 64 * (i/4) + 128;
|
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
for( j = 0; j < 3; j++ )
|
|
|
|
ent->origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j]*f + cl.v_right[j] * r;
|
2007-06-21 22:00:00 +02:00
|
|
|
ent->model = cl.baseclientinfo.model;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
V_TestLights
|
|
|
|
|
|
|
|
If cl_testlights is set, create 32 lights models
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void V_TestLights (void)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
float f, r;
|
|
|
|
dlight_t *dl;
|
|
|
|
|
|
|
|
r_numdlights = 32;
|
|
|
|
memset (r_dlights, 0, sizeof(r_dlights));
|
|
|
|
|
|
|
|
for (i=0 ; i<r_numdlights ; i++)
|
|
|
|
{
|
|
|
|
dl = &r_dlights[i];
|
|
|
|
|
|
|
|
r = 64 * ( (i%4) - 1.5 );
|
|
|
|
f = 64 * (i/4) + 128;
|
|
|
|
|
|
|
|
for (j=0 ; j<3 ; j++)
|
|
|
|
dl->origin[j] = cl.refdef.vieworg[j] + cl.v_forward[j]*f +
|
|
|
|
cl.v_right[j]*r;
|
|
|
|
dl->color[0] = ((i%6)+1) & 1;
|
|
|
|
dl->color[1] = (((i%6)+1) & 2)>>1;
|
|
|
|
dl->color[2] = (((i%6)+1) & 4)>>2;
|
|
|
|
dl->intensity = 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CL_PrepRefresh
|
|
|
|
|
|
|
|
Call before entering a new level, or after changing dlls
|
|
|
|
=================
|
|
|
|
*/
|
2007-11-06 22:00:00 +01:00
|
|
|
void CL_PrepRefresh( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
|
|
|
char mapname[32];
|
2008-01-13 22:00:00 +01:00
|
|
|
string name;
|
2007-06-21 22:00:00 +02:00
|
|
|
float rotate;
|
|
|
|
vec3_t axis;
|
2007-11-08 22:00:00 +01:00
|
|
|
int i;
|
|
|
|
int mdlcount = 0, imgcount = 0, cl_count = 0;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
if (!cl.configstrings[CS_MODELS+1][0])
|
2007-11-08 22:00:00 +01:00
|
|
|
return; // no map loaded
|
2008-07-11 22:00:00 +02:00
|
|
|
|
2008-06-03 22:00:00 +02:00
|
|
|
Msg("CL_PrepRefresh: %s\n", cl.configstrings[CS_NAME] );
|
|
|
|
|
2007-06-21 22:00:00 +02:00
|
|
|
// let the render dll load the map
|
2007-11-08 22:00:00 +01:00
|
|
|
FS_FileBase( cl.configstrings[CS_MODELS+1], mapname );
|
|
|
|
SCR_UpdateScreen();
|
2008-06-30 22:00:00 +02:00
|
|
|
re->BeginRegistration( mapname ); // load map
|
2007-11-08 22:00:00 +01:00
|
|
|
SCR_UpdateScreen();
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
num_cl_weaponmodels = 1;
|
2008-01-13 22:00:00 +01:00
|
|
|
com.strcpy(cl_weaponmodels[0], "v_glock.mdl");
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2007-11-08 22:00:00 +01:00
|
|
|
for( i = 1; i < MAX_MODELS; i++ )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2007-11-08 22:00:00 +01:00
|
|
|
if(!cl.configstrings[CS_MODELS+i][0])
|
|
|
|
break;
|
|
|
|
mdlcount++; // total num models
|
|
|
|
}
|
|
|
|
for( i = 1; i < MAX_IMAGES; i++ )
|
|
|
|
{
|
|
|
|
if(!cl.configstrings[CS_IMAGES+i][0])
|
|
|
|
break;
|
|
|
|
imgcount++; // total num models
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
{
|
|
|
|
if(!cl.configstrings[CS_PLAYERSKINS+i][0])
|
|
|
|
continue;
|
|
|
|
cl_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// create thread here ?
|
|
|
|
for (i = 1; i < MAX_MODELS && cl.configstrings[CS_MODELS+i][0]; i++)
|
|
|
|
{
|
2008-01-13 22:00:00 +01:00
|
|
|
com.strncpy( name, cl.configstrings[CS_MODELS+i], MAX_STRING );
|
2007-11-08 22:00:00 +01:00
|
|
|
SCR_UpdateScreen();
|
2008-07-11 22:00:00 +02:00
|
|
|
Sys_SendKeyEvents(); // pump message loop
|
2008-01-13 22:00:00 +01:00
|
|
|
|
|
|
|
cl.model_draw[i] = re->RegisterModel( name );
|
2008-07-30 22:00:00 +02:00
|
|
|
cl.models[i] = pe->RegisterModel( name );
|
2007-11-08 22:00:00 +01:00
|
|
|
Cvar_SetValue("scr_loading", scr_loading->value + 50.0f/mdlcount );
|
|
|
|
SCR_UpdateScreen();
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
2007-11-08 22:00:00 +01:00
|
|
|
// create thread here ?
|
|
|
|
SCR_UpdateScreen();
|
|
|
|
for (i = 1; i < MAX_IMAGES && cl.configstrings[CS_IMAGES+i][0]; i++)
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2007-08-17 22:00:00 +02:00
|
|
|
cl.image_precache[i] = re->RegisterPic (cl.configstrings[CS_IMAGES+i]);
|
2008-07-11 22:00:00 +02:00
|
|
|
Sys_SendKeyEvents (); // pump message loop
|
2007-11-08 22:00:00 +01:00
|
|
|
Cvar_SetValue("scr_loading", scr_loading->value + 3.0f/imgcount );
|
|
|
|
SCR_UpdateScreen();
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
2007-11-08 22:00:00 +01:00
|
|
|
|
|
|
|
// create thread here ?
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2007-11-08 22:00:00 +01:00
|
|
|
if(!cl.configstrings[CS_PLAYERSKINS+i][0]) continue;
|
|
|
|
Cvar_SetValue("scr_loading", scr_loading->value + 2.0f/cl_count );
|
2007-06-21 22:00:00 +02:00
|
|
|
SCR_UpdateScreen ();
|
2008-07-11 22:00:00 +02:00
|
|
|
Sys_SendKeyEvents(); // pump message loop
|
2007-11-08 22:00:00 +01:00
|
|
|
CL_ParseClientinfo(i);
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CL_LoadClientinfo (&cl.baseclientinfo, "unnamed\\male/grunt");
|
|
|
|
|
|
|
|
// set sky textures and speed
|
2007-11-08 22:00:00 +01:00
|
|
|
SCR_UpdateScreen();
|
2008-06-13 22:00:00 +02:00
|
|
|
rotate = com.atof(cl.configstrings[CS_SKYROTATE]);
|
2007-11-30 22:00:00 +01:00
|
|
|
com.atov( axis, cl.configstrings[CS_SKYAXIS], 3 );
|
2007-11-08 22:00:00 +01:00
|
|
|
re->SetSky( cl.configstrings[CS_SKY], rotate, axis);
|
|
|
|
Cvar_SetValue("scr_loading", 100.0f ); // all done
|
|
|
|
|
|
|
|
re->EndRegistration (); // the render can now free unneeded stuff
|
|
|
|
Con_ClearNotify(); // clear any lines of console text
|
|
|
|
SCR_UpdateScreen();
|
2007-06-21 22:00:00 +02:00
|
|
|
cl.refresh_prepped = true;
|
2007-11-08 22:00:00 +01:00
|
|
|
cl.force_refdef = true;
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
2008-06-28 22:00:00 +02:00
|
|
|
V_CalcFov
|
2007-06-21 22:00:00 +02:00
|
|
|
====================
|
|
|
|
*/
|
2008-06-28 22:00:00 +02:00
|
|
|
float V_CalcFov( float fov_x, float width, float height )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2008-01-12 22:00:00 +01:00
|
|
|
float fov_y, x, rad = 360.0f * M_PI;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-01-12 22:00:00 +01:00
|
|
|
fov_x = bound( 1, fov_x, 179 );
|
|
|
|
x = width / tan( fov_x / rad );
|
|
|
|
fov_y = atan2( height, x );
|
|
|
|
fov_y = (fov_y * rad);
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-01-12 22:00:00 +01:00
|
|
|
return fov_y;
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_RenderView
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2007-11-05 22:00:00 +01:00
|
|
|
void V_RenderView( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2007-11-06 22:00:00 +01:00
|
|
|
if (cls.state != ca_active) return;
|
|
|
|
if (!cl.refresh_prepped) return; // still loading
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
// an invalid frame will just use the exact previous refdef
|
|
|
|
// we can't use the old frame if the video mode has changed, though...
|
|
|
|
if ( cl.frame.valid && (cl.force_refdef || !cl_paused->value) )
|
|
|
|
{
|
|
|
|
cl.force_refdef = false;
|
|
|
|
|
|
|
|
V_ClearScene ();
|
|
|
|
|
|
|
|
// build a refresh entity list and calc cl.sim*
|
|
|
|
// this also calls CL_CalcViewValues which loads
|
|
|
|
// v_forward, etc.
|
2008-07-11 22:00:00 +02:00
|
|
|
CL_VM_Begin();
|
2007-06-21 22:00:00 +02:00
|
|
|
CL_AddEntities ();
|
|
|
|
|
|
|
|
if (cl_testparticles->value)
|
|
|
|
V_TestParticles ();
|
|
|
|
if (cl_testentities->value)
|
|
|
|
V_TestEntities ();
|
|
|
|
if (cl_testlights->value)
|
|
|
|
V_TestLights ();
|
|
|
|
if (cl_testblend->value)
|
|
|
|
{
|
|
|
|
cl.refdef.blend[0] = 1;
|
|
|
|
cl.refdef.blend[1] = 0.5;
|
|
|
|
cl.refdef.blend[2] = 0.25;
|
|
|
|
cl.refdef.blend[3] = 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
// never let it sit exactly on a node line, because a water plane can
|
|
|
|
// dissapear when viewed with the eye exactly on it.
|
|
|
|
// the server protocol only specifies to 1/8 pixel, so add 1/16 in each axis
|
|
|
|
cl.refdef.vieworg[0] += 1.0/16;
|
|
|
|
cl.refdef.vieworg[1] += 1.0/16;
|
|
|
|
cl.refdef.vieworg[2] += 1.0/16;
|
|
|
|
|
|
|
|
cl.refdef.x = scr_vrect.x;
|
|
|
|
cl.refdef.y = scr_vrect.y;
|
|
|
|
cl.refdef.width = scr_vrect.width;
|
|
|
|
cl.refdef.height = scr_vrect.height;
|
2008-06-28 22:00:00 +02:00
|
|
|
cl.refdef.fov_y = V_CalcFov (cl.refdef.fov_x, cl.refdef.width, cl.refdef.height);
|
2008-07-03 22:00:00 +02:00
|
|
|
cl.refdef.time = cl.time * 0.001f; // render use realtime now
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
cl.refdef.areabits = cl.frame.areabits;
|
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
if( !cl_add_entities->value )
|
|
|
|
cls.ref_numents = 0;
|
2007-06-21 22:00:00 +02:00
|
|
|
if (!cl_add_particles->value)
|
|
|
|
r_numparticles = 0;
|
|
|
|
if (!cl_add_lights->value)
|
|
|
|
r_numdlights = 0;
|
|
|
|
if (!cl_add_blend->value)
|
|
|
|
{
|
|
|
|
VectorClear (cl.refdef.blend);
|
|
|
|
}
|
|
|
|
|
2008-07-17 22:00:00 +02:00
|
|
|
cl.refdef.num_entities = cls.ref_numents;
|
|
|
|
cl.refdef.entities = cls.ref_entities;
|
2007-06-21 22:00:00 +02:00
|
|
|
cl.refdef.num_particles = r_numparticles;
|
|
|
|
cl.refdef.particles = r_particles;
|
|
|
|
cl.refdef.num_dlights = r_numdlights;
|
|
|
|
cl.refdef.dlights = r_dlights;
|
|
|
|
cl.refdef.lightstyles = r_lightstyles;
|
|
|
|
|
2008-07-10 22:00:00 +02:00
|
|
|
cl.refdef.rdflags = cl.frame.ps.effects;
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
// sort entities for better cache locality
|
2008-07-17 22:00:00 +02:00
|
|
|
qsort( cl.refdef.entities, cl.refdef.num_entities, sizeof( cl.refdef.entities[0] ), (int(*)(const void *, const void *))entitycmpfnc );
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
2007-08-17 22:00:00 +02:00
|
|
|
re->RenderFrame (&cl.refdef);
|
2008-07-17 22:00:00 +02:00
|
|
|
if( cl_stats->value ) Msg("ent:%i lt:%i part:%i\n", cls.ref_numents, r_numdlights, r_numparticles );
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_PreRender
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
bool V_PreRender( void )
|
|
|
|
{
|
2008-05-18 22:00:00 +02:00
|
|
|
// too early
|
|
|
|
if(!re) return false;
|
2007-11-06 22:00:00 +01:00
|
|
|
|
|
|
|
re->BeginFrame();
|
|
|
|
|
2007-11-13 22:00:00 +01:00
|
|
|
// clear screen
|
|
|
|
SCR_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, g_color_table[0] );
|
|
|
|
|
2007-11-06 22:00:00 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
V_PostRender
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void V_PostRender( void )
|
|
|
|
{
|
2008-06-28 22:00:00 +02:00
|
|
|
UI_Draw();
|
2008-06-30 22:00:00 +02:00
|
|
|
Con_DrawConsole();
|
2007-11-06 22:00:00 +01:00
|
|
|
re->EndFrame();
|
|
|
|
}
|
2007-06-21 22:00:00 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
V_Viewpos_f
|
|
|
|
=============
|
|
|
|
*/
|
2008-06-30 22:00:00 +02:00
|
|
|
void V_Viewpos_f( void )
|
2007-06-21 22:00:00 +02:00
|
|
|
{
|
2008-07-17 22:00:00 +02:00
|
|
|
Msg("(%g %g %g) : %g\n", cl.refdef.vieworg[0], cl.refdef.vieworg[1], cl.refdef.vieworg[2], cl.refdef.viewangles[YAW]);
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
V_Init
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
void V_Init (void)
|
|
|
|
{
|
2007-11-17 22:00:00 +01:00
|
|
|
Cmd_AddCommand ("viewpos", V_Viewpos_f, "prints current player origin" );
|
2007-06-21 22:00:00 +02:00
|
|
|
|
2008-06-29 22:00:00 +02:00
|
|
|
crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, "crosshair style" );
|
|
|
|
cl_testblend = Cvar_Get ("cl_testblend", "0", 0, "test blending" );
|
|
|
|
cl_testparticles = Cvar_Get ("cl_testparticles", "0", 0, "test particle engine" );
|
|
|
|
cl_testentities = Cvar_Get ("cl_testentities", "0", 0, "test client entities" );
|
|
|
|
cl_testlights = Cvar_Get ("cl_testlights", "0", 0, "test dynamic lights" );
|
|
|
|
cl_stats = Cvar_Get ("cl_stats", "0", 0, "enable client stats" );
|
2008-07-17 22:00:00 +02:00
|
|
|
cls.mempool = Mem_AllocPool( "Client Static" );
|
|
|
|
cls.ref_entities = Mem_Alloc( cls.mempool, sizeof(entity_t) * host.max_edicts );
|
2007-06-21 22:00:00 +02:00
|
|
|
}
|
2008-07-17 22:00:00 +02:00
|
|
|
|
|
|
|
void V_Shutdown( void )
|
|
|
|
{
|
|
|
|
Mem_FreePool( &cls.mempool );
|
|
|
|
}
|