mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-22 20:21:41 +00:00
224 lines
4.3 KiB
C
224 lines
4.3 KiB
C
/*
|
|
view.c
|
|
|
|
@description@
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to:
|
|
|
|
Free Software Foundation, Inc.
|
|
59 Temple Place - Suite 330
|
|
Boston, MA 02111-1307, USA
|
|
|
|
$Id$
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
|
|
#include "view.h"
|
|
#include "client.h"
|
|
#include "host.h"
|
|
#include "console.h"
|
|
|
|
byte ramps[3][256];
|
|
float v_blend[4]; // rgba 0.0 - 1.0
|
|
|
|
/*
|
|
=============
|
|
V_CalcBlend
|
|
=============
|
|
*/
|
|
void V_CalcBlend (void)
|
|
{
|
|
float r, g, b, a, a2;
|
|
int j;
|
|
|
|
r = 0;
|
|
g = 0;
|
|
b = 0;
|
|
a = 0;
|
|
|
|
for (j=0 ; j<NUM_CSHIFTS ; j++)
|
|
{
|
|
if (!gl_cshiftpercent->value)
|
|
continue;
|
|
|
|
a2 = ((cl.cshifts[j].percent * gl_cshiftpercent->value) / 100.0) / 255.0;
|
|
|
|
// a2 = cl.cshifts[j].percent/255.0;
|
|
if (!a2)
|
|
continue;
|
|
a = a + a2*(1-a);
|
|
//Con_Printf ("j:%i a:%f\n", j, a);
|
|
a2 = a2/a;
|
|
r = r*(1-a2) + cl.cshifts[j].destcolor[0]*a2;
|
|
g = g*(1-a2) + cl.cshifts[j].destcolor[1]*a2;
|
|
b = b*(1-a2) + cl.cshifts[j].destcolor[2]*a2;
|
|
}
|
|
|
|
v_blend[0] = r/255.0;
|
|
v_blend[1] = g/255.0;
|
|
v_blend[2] = b/255.0;
|
|
v_blend[3] = a;
|
|
if (v_blend[3] > 1)
|
|
v_blend[3] = 1;
|
|
if (v_blend[3] < 0)
|
|
v_blend[3] = 0;
|
|
}
|
|
|
|
/*
|
|
=============
|
|
V_UpdatePalette
|
|
=============
|
|
*/
|
|
void V_UpdatePalette (void)
|
|
{
|
|
int i, j;
|
|
qboolean new;
|
|
qboolean force;
|
|
|
|
V_CalcPowerupCshift ();
|
|
|
|
new = false;
|
|
|
|
for (i=0 ; i<NUM_CSHIFTS ; i++) {
|
|
if (cl.cshifts[i].percent != cl.prev_cshifts[i].percent) {
|
|
new = true;
|
|
cl.prev_cshifts[i].percent = cl.cshifts[i].percent;
|
|
}
|
|
for (j=0 ; j<3 ; j++) {
|
|
if (cl.cshifts[i].destcolor[j] != cl.prev_cshifts[i].destcolor[j]) {
|
|
new = true;
|
|
cl.prev_cshifts[i].destcolor[j] = cl.cshifts[i].destcolor[j];
|
|
}
|
|
}
|
|
}
|
|
|
|
// drop the damage value
|
|
cl.cshifts[CSHIFT_DAMAGE].percent -= host_frametime*150;
|
|
if (cl.cshifts[CSHIFT_DAMAGE].percent <= 0)
|
|
cl.cshifts[CSHIFT_DAMAGE].percent = 0;
|
|
|
|
// drop the bonus value
|
|
cl.cshifts[CSHIFT_BONUS].percent -= host_frametime*100;
|
|
if (cl.cshifts[CSHIFT_BONUS].percent <= 0)
|
|
cl.cshifts[CSHIFT_BONUS].percent = 0;
|
|
|
|
force = V_CheckGamma ();
|
|
if (!new && !force)
|
|
return;
|
|
|
|
V_CalcBlend ();
|
|
}
|
|
|
|
/*
|
|
==============================================================================
|
|
|
|
VIEW RENDERING
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
/*
|
|
==================
|
|
V_RenderView
|
|
|
|
The player's clipping box goes from (-16 -16 -24) to (16 16 32) from
|
|
the entity origin, so any view position inside that will be valid
|
|
==================
|
|
*/
|
|
extern vrect_t scr_vrect;
|
|
|
|
void V_RenderView (void)
|
|
{
|
|
if (con_forcedup)
|
|
return;
|
|
|
|
// don't allow cheats in multiplayer
|
|
if (cl.maxclients > 1)
|
|
{
|
|
Cvar_Set(scr_ofsx, "0");
|
|
Cvar_Set(scr_ofsy, "0");
|
|
Cvar_Set(scr_ofsz, "0");
|
|
}
|
|
|
|
if (cl.intermission)
|
|
{ // intermission / finale rendering
|
|
V_CalcIntermissionRefdef ();
|
|
}
|
|
else
|
|
{
|
|
if (!cl.paused /* && (sv.maxclients > 1 || key_dest == key_game) */ )
|
|
V_CalcRefdef ();
|
|
}
|
|
|
|
R_PushDlights (vec3_origin);
|
|
|
|
if (lcd_x->value)
|
|
{
|
|
//
|
|
// render two interleaved views
|
|
//
|
|
int i;
|
|
|
|
vid.rowbytes <<= 1;
|
|
vid.aspect *= 0.5;
|
|
|
|
r_refdef.viewangles[YAW] -= lcd_yaw->value;
|
|
for (i=0 ; i<3 ; i++)
|
|
r_refdef.vieworg[i] -= right[i]*lcd_x->value;
|
|
R_RenderView ();
|
|
|
|
vid.buffer += vid.rowbytes>>1;
|
|
|
|
R_PushDlights (vec3_origin);
|
|
|
|
r_refdef.viewangles[YAW] += lcd_yaw->value*2;
|
|
for (i=0 ; i<3 ; i++)
|
|
r_refdef.vieworg[i] += 2*right[i]*lcd_x->value;
|
|
R_RenderView ();
|
|
|
|
vid.buffer -= vid.rowbytes>>1;
|
|
|
|
r_refdef.vrect.height <<= 1;
|
|
|
|
vid.rowbytes >>= 1;
|
|
vid.aspect *= 2;
|
|
}
|
|
else
|
|
{
|
|
R_RenderView ();
|
|
}
|
|
}
|
|
|
|
/*
|
|
BuildGammaTable
|
|
|
|
In software mode, this function gets the palette ready for changing...in
|
|
in GL, it does very little as you can see.
|
|
*/
|
|
|
|
void
|
|
BuildGammaTable (float b, float c)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < 256; i++)
|
|
gammatable[i] = i;
|
|
return;
|
|
}
|