2000-05-10 20:33:16 +00:00
|
|
|
/*
|
2000-05-11 16:03:29 +00:00
|
|
|
gl_rmain.c
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
(description)
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
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.
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
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.
|
2000-05-10 20:33:16 +00:00
|
|
|
|
2000-05-11 16:03:29 +00:00
|
|
|
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$
|
2000-05-10 20:33:16 +00:00
|
|
|
*/
|
2000-05-22 06:58:14 +00:00
|
|
|
|
2000-05-17 10:03:19 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2000-05-23 17:05:34 +00:00
|
|
|
# include "config.h"
|
2000-05-17 10:03:19 +00:00
|
|
|
#endif
|
2000-05-23 17:05:34 +00:00
|
|
|
|
2000-05-12 19:17:02 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2000-05-31 17:46:59 +00:00
|
|
|
#include "qargs.h"
|
2000-05-23 17:05:34 +00:00
|
|
|
#include "bothdefs.h"
|
|
|
|
#include "commdef.h"
|
2000-05-12 19:17:02 +00:00
|
|
|
#include "console.h"
|
|
|
|
#include "glquake.h"
|
2000-05-23 17:05:34 +00:00
|
|
|
#include "model.h"
|
|
|
|
#include "render.h"
|
|
|
|
#include "sys.h"
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
entity_t r_worldentity;
|
|
|
|
|
|
|
|
vec3_t modelorg, r_entorigin;
|
|
|
|
entity_t *currententity;
|
|
|
|
|
|
|
|
int r_visframecount; // bumped when going to a new PVS
|
|
|
|
int r_framecount; // used for dlight push checking
|
|
|
|
|
|
|
|
mplane_t frustum[4];
|
|
|
|
|
|
|
|
int c_brush_polys, c_alias_polys;
|
|
|
|
|
|
|
|
qboolean envmap; // true during envmap command capture
|
|
|
|
|
|
|
|
|
|
|
|
int particletexture; // little dot for particles
|
|
|
|
int playertextures; // up to 16 color translated skins
|
|
|
|
|
|
|
|
//
|
|
|
|
// view origin
|
|
|
|
//
|
|
|
|
vec3_t vup;
|
|
|
|
vec3_t vpn;
|
|
|
|
vec3_t vright;
|
|
|
|
vec3_t r_origin;
|
|
|
|
|
|
|
|
float r_world_matrix[16];
|
|
|
|
float r_base_world_matrix[16];
|
|
|
|
|
|
|
|
//
|
|
|
|
// screen size info
|
|
|
|
//
|
|
|
|
refdef_t r_refdef;
|
|
|
|
|
|
|
|
mleaf_t *r_viewleaf, *r_oldviewleaf;
|
|
|
|
|
|
|
|
int d_lightstylevalue[256]; // 8.8 fraction of base light value
|
|
|
|
|
|
|
|
|
2000-06-25 13:00:19 +00:00
|
|
|
vec3_t shadecolor; // Ender (Extend) Colormod
|
2000-06-29 14:32:27 +00:00
|
|
|
float modelalpha; // Ender (EXtend) Alpha
|
2000-06-25 13:00:19 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
void R_MarkLeaves (void);
|
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
cvar_t *r_norefresh;
|
|
|
|
cvar_t *r_drawentities;
|
|
|
|
cvar_t *r_drawviewmodel;
|
|
|
|
cvar_t *r_speeds;
|
|
|
|
cvar_t *r_shadows;
|
|
|
|
cvar_t *r_wateralpha;
|
2000-06-17 10:39:28 +00:00
|
|
|
cvar_t *r_waterripple;
|
2000-05-16 04:47:41 +00:00
|
|
|
cvar_t *r_dynamic;
|
|
|
|
cvar_t *r_novis;
|
|
|
|
cvar_t *r_netgraph;
|
|
|
|
|
|
|
|
cvar_t *gl_clear;
|
|
|
|
cvar_t *gl_cull;
|
|
|
|
cvar_t *gl_texsort;
|
2000-09-28 07:56:00 +00:00
|
|
|
cvar_t *gl_smooth;
|
|
|
|
cvar_t *gl_smoothdlights;
|
2000-05-16 04:47:41 +00:00
|
|
|
cvar_t *gl_affinemodels;
|
|
|
|
cvar_t *gl_polyblend;
|
|
|
|
cvar_t *gl_flashblend;
|
|
|
|
cvar_t *gl_playermip;
|
|
|
|
cvar_t *gl_nocolors;
|
|
|
|
cvar_t *gl_keeptjunctions;
|
2000-06-20 15:31:29 +00:00
|
|
|
cvar_t *gl_particles;
|
2000-05-16 04:47:41 +00:00
|
|
|
|
2000-05-19 03:06:05 +00:00
|
|
|
cvar_t *r_skyname;
|
2000-07-30 02:54:17 +00:00
|
|
|
cvar_t *gl_skymultipass;
|
2000-05-19 03:06:05 +00:00
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
cvar_t *gl_fb_models;
|
|
|
|
cvar_t *gl_fb_bmodels;
|
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
extern cvar_t *scr_fov;
|
2000-05-31 17:46:59 +00:00
|
|
|
|
2000-06-04 09:30:49 +00:00
|
|
|
extern byte gammatable[256];
|
2000-07-02 05:16:10 +00:00
|
|
|
extern qboolean lighthalf;
|
2000-05-31 17:46:59 +00:00
|
|
|
static float vid_gamma = 1.0;
|
|
|
|
|
2000-07-02 05:16:10 +00:00
|
|
|
// LordHavoc: place for gl_rmain setup code
|
|
|
|
void glrmain_init()
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
This is a NON-TRIVIAL update which took LordHavoc and I about 3 days to
make work properly:
Win32 thing.. If you don't free textures explicitly, you can cause a
problem with nVidia drivers.
Colored lighting is now RGB instead of RGBA. The alpha is kinda pointless
on a lightmap and the effect's not all that great. Plus people stuck with
16 bit OpenGL (any other 3dfx people out there?) will be quite pleased
with the improvement in image quality. This does include LordHavoc's
dynamic light optimization code which takes most of the pain out of having
gl_flashblend off.
All glColor*'s are now half of what they used to be, except where they
aren't. If that doesn't make sense, don't worry. If you see one that's
only half what you'd expect, don't worry---it probably is meant to be like
that.. (More below)
glDisable (GL_BLEND) is now a thing of the GL_PAST. As is GL_REPLACE.
Instead, we _always_ use GL_MODULATE and leave GL_BLEND turned on. This
seems at first like it might be a performance hit, but I swear it's much
more expensive to change blending modes and texture functions 20-30 times
every screen frame!
Win32 issue.. Even though we check for multitexture, we currently don't
use it. Reason is that I am planning to replace SGIS_multitexture with
the preferred ARB_multitexture extension which is supported in most GL 1.1
implementations and is a requirement for GL 1.2 anyway. I also wanted to
get rid of some duplicated code. Since Linux doesn't support multitexture
yet, I just commented out the code keeping me from compiling to get it to
work. Win32 should work without it until it's fixed, which shouldn't be
long since the differences between SGIS and ARB multitextures as far as
Quake is concerned is minimal AT BEST.
LordHavoc and I have been working tirelessly (well not quite, we both did
manage to sleep sometime during this ordeal) to fix the lighting in the GL
renderers! It looks DAMNED CLOSE to software's lighting now, including
the ability to overbright a color. You've gotta see this to know what I'm
talking about. That's why the glColor*'s are halved in most places. The
gamma table code and the general way it works is LordHavoc's design, but
over the course of re-implementing it in QF we did come up with a few more
small optimizations.
A lot of people have noticed that QF's fps count has gone to shit lately.
No promises that this undid whatever the problem was. That means there
could be a huge optimization lurking somewhere in the shadows, waiting for
us to fix it for a massive FPS boost. Even if there's not, the code in
this commit DOUBLED MY FPS COUNT. Granted I was getting pathetic FPS as
it was (around 30, which is pathetic even for a Voodoo3 in Linux) but
still---60 is a big improvement over 30!
Please be sure to "test" this code thuroughly.
2000-06-03 19:56:09 +00:00
|
|
|
/*
|
|
|
|
GL_CheckGamma
|
|
|
|
|
|
|
|
More or less redesigned by LordHavoc
|
|
|
|
*/
|
2000-05-31 17:46:59 +00:00
|
|
|
void
|
|
|
|
GL_CheckGamma (unsigned char *pal)
|
|
|
|
{
|
This is a NON-TRIVIAL update which took LordHavoc and I about 3 days to
make work properly:
Win32 thing.. If you don't free textures explicitly, you can cause a
problem with nVidia drivers.
Colored lighting is now RGB instead of RGBA. The alpha is kinda pointless
on a lightmap and the effect's not all that great. Plus people stuck with
16 bit OpenGL (any other 3dfx people out there?) will be quite pleased
with the improvement in image quality. This does include LordHavoc's
dynamic light optimization code which takes most of the pain out of having
gl_flashblend off.
All glColor*'s are now half of what they used to be, except where they
aren't. If that doesn't make sense, don't worry. If you see one that's
only half what you'd expect, don't worry---it probably is meant to be like
that.. (More below)
glDisable (GL_BLEND) is now a thing of the GL_PAST. As is GL_REPLACE.
Instead, we _always_ use GL_MODULATE and leave GL_BLEND turned on. This
seems at first like it might be a performance hit, but I swear it's much
more expensive to change blending modes and texture functions 20-30 times
every screen frame!
Win32 issue.. Even though we check for multitexture, we currently don't
use it. Reason is that I am planning to replace SGIS_multitexture with
the preferred ARB_multitexture extension which is supported in most GL 1.1
implementations and is a requirement for GL 1.2 anyway. I also wanted to
get rid of some duplicated code. Since Linux doesn't support multitexture
yet, I just commented out the code keeping me from compiling to get it to
work. Win32 should work without it until it's fixed, which shouldn't be
long since the differences between SGIS and ARB multitextures as far as
Quake is concerned is minimal AT BEST.
LordHavoc and I have been working tirelessly (well not quite, we both did
manage to sleep sometime during this ordeal) to fix the lighting in the GL
renderers! It looks DAMNED CLOSE to software's lighting now, including
the ability to overbright a color. You've gotta see this to know what I'm
talking about. That's why the glColor*'s are halved in most places. The
gamma table code and the general way it works is LordHavoc's design, but
over the course of re-implementing it in QF we did come up with a few more
small optimizations.
A lot of people have noticed that QF's fps count has gone to shit lately.
No promises that this undid whatever the problem was. That means there
could be a huge optimization lurking somewhere in the shadows, waiting for
us to fix it for a massive FPS boost. Even if there's not, the code in
this commit DOUBLED MY FPS COUNT. Granted I was getting pathetic FPS as
it was (around 30, which is pathetic even for a Voodoo3 in Linux) but
still---60 is a big improvement over 30!
Please be sure to "test" this code thuroughly.
2000-06-03 19:56:09 +00:00
|
|
|
float inf;
|
2000-05-31 17:46:59 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if ((i = COM_CheckParm("-gamma")) == 0) {
|
|
|
|
if ((gl_renderer && strstr(gl_renderer, "Voodoo")) ||
|
|
|
|
(gl_vendor && strstr(gl_vendor, "3Dfx")))
|
|
|
|
vid_gamma = 1;
|
|
|
|
else
|
|
|
|
vid_gamma = 0.7; // default to 0.7 on non-3dfx hardware
|
|
|
|
} else
|
|
|
|
vid_gamma = atof(com_argv[i+1]);
|
|
|
|
|
This is a NON-TRIVIAL update which took LordHavoc and I about 3 days to
make work properly:
Win32 thing.. If you don't free textures explicitly, you can cause a
problem with nVidia drivers.
Colored lighting is now RGB instead of RGBA. The alpha is kinda pointless
on a lightmap and the effect's not all that great. Plus people stuck with
16 bit OpenGL (any other 3dfx people out there?) will be quite pleased
with the improvement in image quality. This does include LordHavoc's
dynamic light optimization code which takes most of the pain out of having
gl_flashblend off.
All glColor*'s are now half of what they used to be, except where they
aren't. If that doesn't make sense, don't worry. If you see one that's
only half what you'd expect, don't worry---it probably is meant to be like
that.. (More below)
glDisable (GL_BLEND) is now a thing of the GL_PAST. As is GL_REPLACE.
Instead, we _always_ use GL_MODULATE and leave GL_BLEND turned on. This
seems at first like it might be a performance hit, but I swear it's much
more expensive to change blending modes and texture functions 20-30 times
every screen frame!
Win32 issue.. Even though we check for multitexture, we currently don't
use it. Reason is that I am planning to replace SGIS_multitexture with
the preferred ARB_multitexture extension which is supported in most GL 1.1
implementations and is a requirement for GL 1.2 anyway. I also wanted to
get rid of some duplicated code. Since Linux doesn't support multitexture
yet, I just commented out the code keeping me from compiling to get it to
work. Win32 should work without it until it's fixed, which shouldn't be
long since the differences between SGIS and ARB multitextures as far as
Quake is concerned is minimal AT BEST.
LordHavoc and I have been working tirelessly (well not quite, we both did
manage to sleep sometime during this ordeal) to fix the lighting in the GL
renderers! It looks DAMNED CLOSE to software's lighting now, including
the ability to overbright a color. You've gotta see this to know what I'm
talking about. That's why the glColor*'s are halved in most places. The
gamma table code and the general way it works is LordHavoc's design, but
over the course of re-implementing it in QF we did come up with a few more
small optimizations.
A lot of people have noticed that QF's fps count has gone to shit lately.
No promises that this undid whatever the problem was. That means there
could be a huge optimization lurking somewhere in the shadows, waiting for
us to fix it for a massive FPS boost. Even if there's not, the code in
this commit DOUBLED MY FPS COUNT. Granted I was getting pathetic FPS as
it was (around 30, which is pathetic even for a Voodoo3 in Linux) but
still---60 is a big improvement over 30!
Please be sure to "test" this code thuroughly.
2000-06-03 19:56:09 +00:00
|
|
|
// build the gamma table
|
|
|
|
if (vid_gamma == 1)
|
2000-05-31 17:46:59 +00:00
|
|
|
{
|
This is a NON-TRIVIAL update which took LordHavoc and I about 3 days to
make work properly:
Win32 thing.. If you don't free textures explicitly, you can cause a
problem with nVidia drivers.
Colored lighting is now RGB instead of RGBA. The alpha is kinda pointless
on a lightmap and the effect's not all that great. Plus people stuck with
16 bit OpenGL (any other 3dfx people out there?) will be quite pleased
with the improvement in image quality. This does include LordHavoc's
dynamic light optimization code which takes most of the pain out of having
gl_flashblend off.
All glColor*'s are now half of what they used to be, except where they
aren't. If that doesn't make sense, don't worry. If you see one that's
only half what you'd expect, don't worry---it probably is meant to be like
that.. (More below)
glDisable (GL_BLEND) is now a thing of the GL_PAST. As is GL_REPLACE.
Instead, we _always_ use GL_MODULATE and leave GL_BLEND turned on. This
seems at first like it might be a performance hit, but I swear it's much
more expensive to change blending modes and texture functions 20-30 times
every screen frame!
Win32 issue.. Even though we check for multitexture, we currently don't
use it. Reason is that I am planning to replace SGIS_multitexture with
the preferred ARB_multitexture extension which is supported in most GL 1.1
implementations and is a requirement for GL 1.2 anyway. I also wanted to
get rid of some duplicated code. Since Linux doesn't support multitexture
yet, I just commented out the code keeping me from compiling to get it to
work. Win32 should work without it until it's fixed, which shouldn't be
long since the differences between SGIS and ARB multitextures as far as
Quake is concerned is minimal AT BEST.
LordHavoc and I have been working tirelessly (well not quite, we both did
manage to sleep sometime during this ordeal) to fix the lighting in the GL
renderers! It looks DAMNED CLOSE to software's lighting now, including
the ability to overbright a color. You've gotta see this to know what I'm
talking about. That's why the glColor*'s are halved in most places. The
gamma table code and the general way it works is LordHavoc's design, but
over the course of re-implementing it in QF we did come up with a few more
small optimizations.
A lot of people have noticed that QF's fps count has gone to shit lately.
No promises that this undid whatever the problem was. That means there
could be a huge optimization lurking somewhere in the shadows, waiting for
us to fix it for a massive FPS boost. Even if there's not, the code in
this commit DOUBLED MY FPS COUNT. Granted I was getting pathetic FPS as
it was (around 30, which is pathetic even for a Voodoo3 in Linux) but
still---60 is a big improvement over 30!
Please be sure to "test" this code thuroughly.
2000-06-03 19:56:09 +00:00
|
|
|
// screw the math
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
gammatable[i] = i;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
inf = pow((i+1)/256.0, vid_gamma)*255 + 0.5;
|
|
|
|
inf = bound(0, inf, 255);
|
|
|
|
gammatable[i] = inf;
|
|
|
|
}
|
2000-05-31 17:46:59 +00:00
|
|
|
}
|
|
|
|
|
This is a NON-TRIVIAL update which took LordHavoc and I about 3 days to
make work properly:
Win32 thing.. If you don't free textures explicitly, you can cause a
problem with nVidia drivers.
Colored lighting is now RGB instead of RGBA. The alpha is kinda pointless
on a lightmap and the effect's not all that great. Plus people stuck with
16 bit OpenGL (any other 3dfx people out there?) will be quite pleased
with the improvement in image quality. This does include LordHavoc's
dynamic light optimization code which takes most of the pain out of having
gl_flashblend off.
All glColor*'s are now half of what they used to be, except where they
aren't. If that doesn't make sense, don't worry. If you see one that's
only half what you'd expect, don't worry---it probably is meant to be like
that.. (More below)
glDisable (GL_BLEND) is now a thing of the GL_PAST. As is GL_REPLACE.
Instead, we _always_ use GL_MODULATE and leave GL_BLEND turned on. This
seems at first like it might be a performance hit, but I swear it's much
more expensive to change blending modes and texture functions 20-30 times
every screen frame!
Win32 issue.. Even though we check for multitexture, we currently don't
use it. Reason is that I am planning to replace SGIS_multitexture with
the preferred ARB_multitexture extension which is supported in most GL 1.1
implementations and is a requirement for GL 1.2 anyway. I also wanted to
get rid of some duplicated code. Since Linux doesn't support multitexture
yet, I just commented out the code keeping me from compiling to get it to
work. Win32 should work without it until it's fixed, which shouldn't be
long since the differences between SGIS and ARB multitextures as far as
Quake is concerned is minimal AT BEST.
LordHavoc and I have been working tirelessly (well not quite, we both did
manage to sleep sometime during this ordeal) to fix the lighting in the GL
renderers! It looks DAMNED CLOSE to software's lighting now, including
the ability to overbright a color. You've gotta see this to know what I'm
talking about. That's why the glColor*'s are halved in most places. The
gamma table code and the general way it works is LordHavoc's design, but
over the course of re-implementing it in QF we did come up with a few more
small optimizations.
A lot of people have noticed that QF's fps count has gone to shit lately.
No promises that this undid whatever the problem was. That means there
could be a huge optimization lurking somewhere in the shadows, waiting for
us to fix it for a massive FPS boost. Even if there's not, the code in
this commit DOUBLED MY FPS COUNT. Granted I was getting pathetic FPS as
it was (around 30, which is pathetic even for a Voodoo3 in Linux) but
still---60 is a big improvement over 30!
Please be sure to "test" this code thuroughly.
2000-06-03 19:56:09 +00:00
|
|
|
// correct the palette
|
|
|
|
for (i = 0; i < 768; i++)
|
|
|
|
pal[i] = gammatable[pal[i]];
|
2000-05-31 17:46:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
R_CullBox
|
|
|
|
|
|
|
|
Returns true if the box is completely outside the frustom
|
|
|
|
=================
|
|
|
|
*/
|
2000-09-26 09:03:21 +00:00
|
|
|
/*
|
2000-05-10 11:29:38 +00:00
|
|
|
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;
|
|
|
|
}
|
2000-09-26 09:03:21 +00:00
|
|
|
*/
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
void R_RotateForEntity (entity_t *e)
|
|
|
|
{
|
|
|
|
glTranslatef (e->origin[0], e->origin[1], e->origin[2]);
|
|
|
|
|
|
|
|
glRotatef (e->angles[1], 0, 0, 1);
|
|
|
|
glRotatef (-e->angles[0], 0, 1, 0);
|
|
|
|
//ZOID: fixed z angle
|
|
|
|
glRotatef (e->angles[2], 1, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================
|
|
|
|
|
|
|
|
SPRITE MODELS
|
|
|
|
|
|
|
|
=============================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
R_GetSpriteFrame
|
|
|
|
================
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static mspriteframe_t *R_GetSpriteFrame (entity_t *currententity)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
msprite_t *psprite;
|
|
|
|
mspritegroup_t *pspritegroup;
|
|
|
|
mspriteframe_t *pspriteframe;
|
|
|
|
int i, numframes, frame;
|
|
|
|
float *pintervals, fullinterval, targettime, time;
|
|
|
|
|
|
|
|
psprite = currententity->model->cache.data;
|
|
|
|
frame = currententity->frame;
|
|
|
|
|
|
|
|
if ((frame >= psprite->numframes) || (frame < 0))
|
|
|
|
{
|
|
|
|
Con_Printf ("R_DrawSprite: no such frame %d\n", frame);
|
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (psprite->frames[frame].type == SPR_SINGLE)
|
|
|
|
{
|
|
|
|
pspriteframe = psprite->frames[frame].frameptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
|
|
|
|
pintervals = pspritegroup->intervals;
|
|
|
|
numframes = pspritegroup->numframes;
|
|
|
|
fullinterval = pintervals[numframes-1];
|
|
|
|
|
|
|
|
time = cl.time + currententity->syncbase;
|
|
|
|
|
|
|
|
// when loading in Mod_LoadSpriteGroup, we guaranteed all interval values
|
|
|
|
// are positive, so we don't have to worry about division by 0
|
|
|
|
targettime = time - ((int)(time / fullinterval)) * fullinterval;
|
|
|
|
|
|
|
|
for (i=0 ; i<(numframes-1) ; i++)
|
|
|
|
{
|
|
|
|
if (pintervals[i] > targettime)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pspriteframe = pspritegroup->frames[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return pspriteframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
R_DrawSpriteModel
|
|
|
|
|
|
|
|
=================
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_DrawSpriteModel (entity_t *e)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
vec3_t point;
|
|
|
|
mspriteframe_t *frame;
|
|
|
|
float *up, *right;
|
|
|
|
vec3_t v_forward, v_right, v_up;
|
|
|
|
msprite_t *psprite;
|
|
|
|
|
|
|
|
// don't even bother culling, because it's just a single
|
|
|
|
// polygon without a surface cache
|
|
|
|
frame = R_GetSpriteFrame (e);
|
|
|
|
psprite = currententity->model->cache.data;
|
|
|
|
|
|
|
|
if (psprite->type == SPR_ORIENTED)
|
|
|
|
{ // bullet marks on walls
|
|
|
|
AngleVectors (currententity->angles, v_forward, v_right, v_up);
|
|
|
|
up = v_up;
|
|
|
|
right = v_right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // normal sprite
|
|
|
|
up = vup;
|
|
|
|
right = vright;
|
|
|
|
}
|
|
|
|
|
2000-06-17 10:39:28 +00:00
|
|
|
glBindTexture (GL_TEXTURE_2D, frame->gl_texturenum);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
glEnable (GL_ALPHA_TEST);
|
|
|
|
glBegin (GL_QUADS);
|
|
|
|
|
|
|
|
glTexCoord2f (0, 1);
|
|
|
|
VectorMA (e->origin, frame->down, up, point);
|
|
|
|
VectorMA (point, frame->left, right, point);
|
|
|
|
glVertex3fv (point);
|
|
|
|
|
|
|
|
glTexCoord2f (0, 0);
|
|
|
|
VectorMA (e->origin, frame->up, up, point);
|
|
|
|
VectorMA (point, frame->left, right, point);
|
|
|
|
glVertex3fv (point);
|
|
|
|
|
|
|
|
glTexCoord2f (1, 0);
|
|
|
|
VectorMA (e->origin, frame->up, up, point);
|
|
|
|
VectorMA (point, frame->right, right, point);
|
|
|
|
glVertex3fv (point);
|
|
|
|
|
|
|
|
glTexCoord2f (1, 1);
|
|
|
|
VectorMA (e->origin, frame->down, up, point);
|
|
|
|
VectorMA (point, frame->right, right, point);
|
|
|
|
glVertex3fv (point);
|
|
|
|
|
|
|
|
glEnd ();
|
|
|
|
|
|
|
|
glDisable (GL_ALPHA_TEST);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================
|
|
|
|
|
|
|
|
ALIAS MODELS
|
|
|
|
|
|
|
|
=============================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#define NUMVERTEXNORMALS 162
|
|
|
|
|
|
|
|
float r_avertexnormals[NUMVERTEXNORMALS][3] = {
|
|
|
|
#include "anorms.h"
|
|
|
|
};
|
|
|
|
|
|
|
|
vec3_t shadevector;
|
2000-09-26 09:03:21 +00:00
|
|
|
float shadelight;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// precalculated dot products for quantized angles
|
|
|
|
#define SHADEDOT_QUANT 16
|
|
|
|
float r_avertexnormal_dots[SHADEDOT_QUANT][256] =
|
|
|
|
#include "anorm_dots.h"
|
|
|
|
;
|
|
|
|
|
|
|
|
float *shadedots = r_avertexnormal_dots[0];
|
|
|
|
|
|
|
|
int lastposenum;
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
GL_DrawAliasFrame
|
|
|
|
=============
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void GL_DrawAliasFrame (aliashdr_t *paliashdr, int posenum, qboolean fb)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
float l;
|
|
|
|
trivertx_t *verts;
|
|
|
|
int *order;
|
|
|
|
int count;
|
2000-06-17 10:39:28 +00:00
|
|
|
|
|
|
|
lastposenum = posenum;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
verts = (trivertx_t *)((byte *)paliashdr + paliashdr->posedata);
|
|
|
|
verts += posenum * paliashdr->poseverts;
|
|
|
|
order = (int *)((byte *)paliashdr + paliashdr->commands);
|
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
if (modelalpha != 1.0)
|
2000-06-30 10:29:57 +00:00
|
|
|
glDepthMask(0);
|
2000-06-29 14:32:27 +00:00
|
|
|
|
2000-09-28 06:58:24 +00:00
|
|
|
while ((count = *order++)) {
|
2000-05-10 11:29:38 +00:00
|
|
|
// get the vertex count and primitive type
|
2000-09-28 06:58:24 +00:00
|
|
|
if (count < 0) {
|
2000-05-10 11:29:38 +00:00
|
|
|
count = -count;
|
|
|
|
glBegin (GL_TRIANGLE_FAN);
|
2000-09-28 06:58:24 +00:00
|
|
|
} else
|
2000-05-10 11:29:38 +00:00
|
|
|
glBegin (GL_TRIANGLE_STRIP);
|
|
|
|
|
2000-09-28 06:58:24 +00:00
|
|
|
do {
|
2000-05-10 11:29:38 +00:00
|
|
|
// texture coordinates come from the draw list
|
|
|
|
glTexCoord2f (((float *)order)[0], ((float *)order)[1]);
|
|
|
|
order += 2;
|
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
if (fb) {
|
|
|
|
glColor4f (1, 1, 1, modelalpha);
|
|
|
|
} else {
|
|
|
|
// normals and vertexes come from the frame list
|
|
|
|
l = shadedots[verts->lightnormalindex] * shadelight;
|
2000-06-30 00:47:26 +00:00
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
// LordHavoc: cleanup after Endy
|
|
|
|
glColor4f(shadecolor[0] * l, shadecolor[1] * l, shadecolor[2] * l, modelalpha);
|
|
|
|
}
|
2000-06-25 20:53:26 +00:00
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
glVertex3f (verts->v[0], verts->v[1], verts->v[2]);
|
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
|
|
|
glEnd ();
|
|
|
|
}
|
2000-06-29 14:32:27 +00:00
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
if (modelalpha != 1.0)
|
|
|
|
glDepthMask(1);
|
2000-09-28 00:22:24 +00:00
|
|
|
glColor3ubv(lighthalf_v);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
GL_DrawAliasShadow
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
extern vec3_t lightspot;
|
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
static void GL_DrawAliasShadow (aliashdr_t *paliashdr, int posenum)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
trivertx_t *verts;
|
|
|
|
int *order;
|
|
|
|
vec3_t point;
|
|
|
|
float height, lheight;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
lheight = currententity->origin[2] - lightspot[2];
|
|
|
|
|
|
|
|
height = 0;
|
|
|
|
verts = (trivertx_t *)((byte *)paliashdr + paliashdr->posedata);
|
|
|
|
verts += posenum * paliashdr->poseverts;
|
|
|
|
order = (int *)((byte *)paliashdr + paliashdr->commands);
|
|
|
|
|
|
|
|
height = -lheight + 1.0;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
// get the vertex count and primitive type
|
|
|
|
count = *order++;
|
|
|
|
if (!count)
|
|
|
|
break; // done
|
|
|
|
if (count < 0)
|
|
|
|
{
|
|
|
|
count = -count;
|
|
|
|
glBegin (GL_TRIANGLE_FAN);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
glBegin (GL_TRIANGLE_STRIP);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
// texture coordinates come from the draw list
|
|
|
|
// (skipped for shadows) glTexCoord2fv ((float *)order);
|
|
|
|
order += 2;
|
|
|
|
|
|
|
|
// normals and vertexes come from the frame list
|
2000-09-20 22:11:17 +00:00
|
|
|
point[0] = verts->v[0] * paliashdr->mdl.scale[0] + 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];
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
point[0] -= shadevector[0]*(point[2]+lheight);
|
|
|
|
point[1] -= shadevector[1]*(point[2]+lheight);
|
|
|
|
point[2] = height;
|
|
|
|
// height -= 0.001;
|
|
|
|
glVertex3fv (point);
|
|
|
|
|
|
|
|
verts++;
|
|
|
|
} while (--count);
|
|
|
|
|
|
|
|
glEnd ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
R_SetupAliasFrame
|
|
|
|
|
|
|
|
=================
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_SetupAliasFrame (int frame, aliashdr_t *paliashdr, qboolean fb)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
int pose, numposes;
|
|
|
|
float interval;
|
|
|
|
|
2000-09-20 22:11:17 +00:00
|
|
|
if ((frame >= paliashdr->mdl.numframes) || (frame < 0))
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
Con_DPrintf ("R_AliasSetupFrame: no such frame %d\n", frame);
|
|
|
|
frame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pose = paliashdr->frames[frame].firstpose;
|
|
|
|
numposes = paliashdr->frames[frame].numposes;
|
|
|
|
|
|
|
|
if (numposes > 1)
|
|
|
|
{
|
|
|
|
interval = paliashdr->frames[frame].interval;
|
|
|
|
pose += (int)(cl.time / interval) % numposes;
|
|
|
|
}
|
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
GL_DrawAliasFrame (paliashdr, pose, fb);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
R_DrawAliasModel
|
|
|
|
|
|
|
|
=================
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_DrawAliasModel (entity_t *e)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int lnum;
|
|
|
|
vec3_t dist;
|
|
|
|
float add;
|
|
|
|
model_t *clmodel;
|
|
|
|
vec3_t mins, maxs;
|
|
|
|
aliashdr_t *paliashdr;
|
|
|
|
float an;
|
|
|
|
int anim;
|
|
|
|
|
|
|
|
clmodel = currententity->model;
|
|
|
|
|
|
|
|
VectorAdd (currententity->origin, clmodel->mins, mins);
|
|
|
|
VectorAdd (currententity->origin, clmodel->maxs, maxs);
|
|
|
|
|
|
|
|
if (R_CullBox (mins, maxs))
|
|
|
|
return;
|
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
// FIXME: shadecolor is supposed to be the lighting for the model, not just colormod
|
|
|
|
shadecolor[0] = currententity->colormod[0];
|
|
|
|
shadecolor[1] = currententity->colormod[1];
|
|
|
|
shadecolor[2] = currententity->colormod[2];
|
2000-07-04 03:10:31 +00:00
|
|
|
if (!lighthalf)
|
2000-07-02 05:16:10 +00:00
|
|
|
{
|
2000-07-04 03:10:31 +00:00
|
|
|
shadecolor[0] *= 2.0;
|
|
|
|
shadecolor[1] *= 2.0;
|
|
|
|
shadecolor[2] *= 2.0;
|
2000-07-02 05:16:10 +00:00
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
VectorCopy (currententity->origin, r_entorigin);
|
|
|
|
VectorSubtract (r_origin, r_entorigin, modelorg);
|
|
|
|
|
|
|
|
//
|
|
|
|
// get lighting information
|
|
|
|
//
|
|
|
|
|
2000-09-26 09:03:21 +00:00
|
|
|
shadelight = R_LightPoint (currententity->origin);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// allways give the gun some light
|
2000-09-26 09:03:21 +00:00
|
|
|
if (e == &cl.viewent)
|
2000-10-07 04:06:08 +00:00
|
|
|
shadelight = max(shadelight, 24);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
for (lnum=0 ; lnum<MAX_DLIGHTS ; lnum++)
|
|
|
|
{
|
|
|
|
if (cl_dlights[lnum].die >= cl.time)
|
|
|
|
{
|
|
|
|
VectorSubtract (currententity->origin,
|
|
|
|
cl_dlights[lnum].origin,
|
|
|
|
dist);
|
2000-08-27 11:05:11 +00:00
|
|
|
add = (cl_dlights[lnum].radius * cl_dlights[lnum].radius * 8) / (DotProduct(dist, dist)); // FIXME Deek
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
if (add > 0)
|
|
|
|
{
|
2000-05-10 11:29:38 +00:00
|
|
|
shadelight += add;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// clamp lighting so it doesn't overbright as much
|
2000-09-26 09:03:21 +00:00
|
|
|
shadelight = min(shadelight, 100);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// ZOID: never allow players to go totally black
|
2000-06-30 00:47:26 +00:00
|
|
|
if (!strcmp(clmodel->name, "progs/player.mdl"))
|
|
|
|
{
|
2000-09-26 09:03:21 +00:00
|
|
|
shadelight = max(shadelight, 8);
|
2000-08-16 09:26:22 +00:00
|
|
|
} else if (!gl_fb_models->value && (
|
|
|
|
!strcmp (clmodel->name, "progs/flame.mdl") ||
|
|
|
|
!strcmp (clmodel->name, "progs/flame2.mdl"))) {
|
2000-05-10 11:29:38 +00:00
|
|
|
// HACK HACK HACK -- no fullbright colors, so make torches full light
|
2000-09-26 09:03:21 +00:00
|
|
|
shadelight = 256;
|
2000-08-16 09:26:22 +00:00
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
shadedots = r_avertexnormal_dots[((int)(e->angles[1] * (SHADEDOT_QUANT / 360.0))) & (SHADEDOT_QUANT - 1)];
|
2000-09-26 09:03:21 +00:00
|
|
|
shadelight /= 200.0;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
an = e->angles[1]/180*M_PI;
|
|
|
|
shadevector[0] = cos(-an);
|
|
|
|
shadevector[1] = sin(-an);
|
|
|
|
shadevector[2] = 1;
|
|
|
|
VectorNormalize (shadevector);
|
|
|
|
|
|
|
|
//
|
|
|
|
// locate the proper data
|
|
|
|
//
|
|
|
|
paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);
|
|
|
|
|
2000-09-20 22:11:17 +00:00
|
|
|
c_alias_polys += paliashdr->mdl.numtris;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// draw all the triangles
|
|
|
|
//
|
|
|
|
|
2000-06-17 10:39:28 +00:00
|
|
|
glPushMatrix ();
|
2000-05-10 11:29:38 +00:00
|
|
|
R_RotateForEntity (e);
|
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
if (!strcmp (clmodel->name, "progs/eyes.mdl") )
|
|
|
|
{
|
2000-09-20 22:11:17 +00:00
|
|
|
glTranslatef (paliashdr->mdl.scale_origin[0], paliashdr->mdl.scale_origin[1], paliashdr->mdl.scale_origin[2] - (22 + 8));
|
2000-05-10 11:29:38 +00:00
|
|
|
// double size of eyes, since they are really hard to see in gl
|
2000-09-20 22:11:17 +00:00
|
|
|
glScalef (paliashdr->mdl.scale[0]*2, paliashdr->mdl.scale[1]*2, paliashdr->mdl.scale[2]*2);
|
2000-06-30 00:47:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-09-20 22:11:17 +00:00
|
|
|
glTranslatef (paliashdr->mdl.scale_origin[0], paliashdr->mdl.scale_origin[1], paliashdr->mdl.scale_origin[2]);
|
|
|
|
glScalef (paliashdr->mdl.scale[0], paliashdr->mdl.scale[1], paliashdr->mdl.scale[2]);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
anim = (int)(cl.time*10) & 3;
|
2000-06-17 10:39:28 +00:00
|
|
|
glBindTexture (GL_TEXTURE_2D, paliashdr->gl_texturenum[currententity->skinnum][anim]);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
// we can't dynamically colormap textures, so they are cached
|
|
|
|
// seperately for the players. Heads are just uncolored.
|
2000-05-16 04:47:41 +00:00
|
|
|
if (currententity->scoreboard && !gl_nocolors->value)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
i = currententity->scoreboard - cl.players;
|
2000-06-30 00:47:26 +00:00
|
|
|
if (!currententity->scoreboard->skin)
|
|
|
|
{
|
2000-05-10 11:29:38 +00:00
|
|
|
Skin_Find(currententity->scoreboard);
|
|
|
|
R_TranslatePlayerSkin(i);
|
|
|
|
}
|
|
|
|
if (i >= 0 && i<MAX_CLIENTS)
|
2000-06-17 10:39:28 +00:00
|
|
|
glBindTexture (GL_TEXTURE_2D, playertextures + i);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
if (gl_affinemodels->value)
|
2000-09-28 07:56:00 +00:00
|
|
|
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
R_SetupAliasFrame (currententity->frame, paliashdr, false);
|
|
|
|
|
|
|
|
// This block is GL fullbright support for objects...
|
2000-08-16 12:29:13 +00:00
|
|
|
if (clmodel->hasfullbrights && gl_fb_models->value &&
|
|
|
|
paliashdr->gl_fb_texturenum[currententity->skinnum][anim]) {
|
2000-08-16 09:26:22 +00:00
|
|
|
glBindTexture (GL_TEXTURE_2D, paliashdr->gl_fb_texturenum[currententity->skinnum][anim]);
|
|
|
|
R_SetupAliasFrame (currententity->frame, paliashdr, true);
|
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
if (gl_affinemodels->value)
|
2000-09-28 07:56:00 +00:00
|
|
|
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
glPopMatrix ();
|
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
if (r_shadows->value)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
glPushMatrix ();
|
|
|
|
R_RotateForEntity (e);
|
|
|
|
glDisable (GL_TEXTURE_2D);
|
|
|
|
glColor4f (0,0,0,0.5);
|
|
|
|
GL_DrawAliasShadow (paliashdr, lastposenum);
|
|
|
|
glEnable (GL_TEXTURE_2D);
|
2000-09-28 00:22:24 +00:00
|
|
|
glColor3ubv(lighthalf_v);
|
2000-05-10 11:29:38 +00:00
|
|
|
glPopMatrix ();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_DrawEntitiesOnList
|
|
|
|
=============
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_DrawEntitiesOnList (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2000-05-16 04:47:41 +00:00
|
|
|
if (!r_drawentities->value)
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
// LordHavoc: split into 3 loops to simplify state changes
|
2000-05-10 11:29:38 +00:00
|
|
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
|
|
|
{
|
2000-06-30 00:47:26 +00:00
|
|
|
if (cl_visedicts[i].model->type != mod_brush)
|
|
|
|
continue;
|
2000-05-10 11:29:38 +00:00
|
|
|
currententity = &cl_visedicts[i];
|
2000-06-30 00:47:26 +00:00
|
|
|
modelalpha = currententity->alpha;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
R_DrawBrushModel (currententity);
|
|
|
|
}
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
|
|
|
{
|
2000-06-30 06:26:17 +00:00
|
|
|
if (cl_visedicts[i].model->type != mod_alias)
|
2000-06-30 00:47:26 +00:00
|
|
|
continue;
|
|
|
|
currententity = &cl_visedicts[i];
|
|
|
|
modelalpha = currententity->alpha;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
R_DrawAliasModel (currententity);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
|
|
|
{
|
2000-06-30 00:47:26 +00:00
|
|
|
if (cl_visedicts[i].model->type != mod_sprite)
|
|
|
|
continue;
|
2000-05-10 11:29:38 +00:00
|
|
|
currententity = &cl_visedicts[i];
|
2000-06-30 06:26:17 +00:00
|
|
|
modelalpha = currententity->alpha;
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-06-30 00:47:26 +00:00
|
|
|
R_DrawSpriteModel (currententity);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_DrawViewModel
|
|
|
|
=============
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_DrawViewModel (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-06-30 09:59:02 +00:00
|
|
|
currententity = &cl.viewent;
|
2000-06-30 00:47:26 +00:00
|
|
|
if (!r_drawviewmodel->value
|
|
|
|
|| !Cam_DrawViewModel()
|
|
|
|
|| envmap
|
|
|
|
|| !r_drawentities->value
|
|
|
|
|| (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
|
2000-06-30 10:07:04 +00:00
|
|
|
|| cl.stats[STAT_HEALTH] <= 0
|
2000-06-30 09:59:02 +00:00
|
|
|
|| !currententity->model)
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
|
2000-07-01 05:54:12 +00:00
|
|
|
// this is a HACK! --KB
|
|
|
|
modelalpha = currententity->alpha;
|
|
|
|
|
2000-05-10 11:29:38 +00:00
|
|
|
// hack the depth range to prevent view model from poking into walls
|
|
|
|
glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
|
|
|
|
R_DrawAliasModel (currententity);
|
|
|
|
glDepthRange (gldepthmin, gldepthmax);
|
|
|
|
}
|
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
static int SignbitsForPlane (mplane_t *out)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
int bits, j;
|
|
|
|
|
|
|
|
// for fast box on planeside test
|
|
|
|
|
|
|
|
bits = 0;
|
|
|
|
for (j=0 ; j<3 ; j++)
|
|
|
|
{
|
|
|
|
if (out->normal[j] < 0)
|
|
|
|
bits |= 1<<j;
|
|
|
|
}
|
|
|
|
return bits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_SetFrustum (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (r_refdef.fov_x == 90)
|
|
|
|
{
|
|
|
|
// front side is visible
|
|
|
|
|
|
|
|
VectorAdd (vpn, vright, frustum[0].normal);
|
|
|
|
VectorSubtract (vpn, vright, frustum[1].normal);
|
|
|
|
|
|
|
|
VectorAdd (vpn, vup, frustum[2].normal);
|
|
|
|
VectorSubtract (vpn, vup, frustum[3].normal);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
// rotate VPN right by FOV_X/2 degrees
|
|
|
|
RotatePointAroundVector( frustum[0].normal, vup, vpn, -(90-r_refdef.fov_x / 2 ) );
|
|
|
|
// rotate VPN left by FOV_X/2 degrees
|
|
|
|
RotatePointAroundVector( frustum[1].normal, vup, vpn, 90-r_refdef.fov_x / 2 );
|
|
|
|
// rotate VPN up by FOV_X/2 degrees
|
|
|
|
RotatePointAroundVector( frustum[2].normal, vright, vpn, 90-r_refdef.fov_y / 2 );
|
|
|
|
// rotate VPN down by FOV_X/2 degrees
|
|
|
|
RotatePointAroundVector( frustum[3].normal, vright, vpn, -( 90 - r_refdef.fov_y / 2 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0 ; i<4 ; i++)
|
|
|
|
{
|
|
|
|
frustum[i].type = PLANE_ANYZ;
|
|
|
|
frustum[i].dist = DotProduct (r_origin, frustum[i].normal);
|
|
|
|
frustum[i].signbits = SignbitsForPlane (&frustum[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
R_SetupFrame
|
|
|
|
===============
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_SetupFrame (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
// don't allow cheats in multiplayer
|
|
|
|
if (!atoi(Info_ValueForKey(cl.serverinfo, "watervis")))
|
2000-05-23 17:05:34 +00:00
|
|
|
Cvar_SetValue(r_wateralpha, 1);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
R_AnimateLight ();
|
|
|
|
|
|
|
|
r_framecount++;
|
|
|
|
|
|
|
|
// build the transformation matrix for the given view angles
|
|
|
|
VectorCopy (r_refdef.vieworg, r_origin);
|
|
|
|
|
|
|
|
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
|
|
|
|
|
|
|
|
// current viewleaf
|
|
|
|
r_oldviewleaf = r_viewleaf;
|
|
|
|
r_viewleaf = Mod_PointInLeaf (r_origin, cl.worldmodel);
|
|
|
|
|
|
|
|
V_SetContentsColor (r_viewleaf->contents);
|
|
|
|
V_CalcBlend ();
|
|
|
|
|
|
|
|
c_brush_polys = 0;
|
|
|
|
c_alias_polys = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-16 09:26:22 +00:00
|
|
|
static void MYgluPerspective( GLdouble fovy, GLdouble aspect,
|
2000-05-10 11:29:38 +00:00
|
|
|
GLdouble zNear, GLdouble zFar )
|
|
|
|
{
|
|
|
|
GLdouble xmin, xmax, ymin, ymax;
|
|
|
|
|
|
|
|
ymax = zNear * tan( fovy * M_PI / 360.0 );
|
|
|
|
ymin = -ymax;
|
|
|
|
|
|
|
|
xmin = ymin * aspect;
|
|
|
|
xmax = ymax * aspect;
|
|
|
|
|
|
|
|
glFrustum( xmin, xmax, ymin, ymax, zNear, zFar );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_SetupGL
|
|
|
|
=============
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_SetupGL (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
float screenaspect;
|
|
|
|
extern int glwidth, glheight;
|
|
|
|
int x, x2, y2, y, w, h;
|
|
|
|
|
|
|
|
//
|
|
|
|
// set up viewpoint
|
|
|
|
//
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity ();
|
|
|
|
x = r_refdef.vrect.x * glwidth/vid.width;
|
|
|
|
x2 = (r_refdef.vrect.x + r_refdef.vrect.width) * glwidth/vid.width;
|
|
|
|
y = (vid.height-r_refdef.vrect.y) * glheight/vid.height;
|
|
|
|
y2 = (vid.height - (r_refdef.vrect.y + r_refdef.vrect.height)) * glheight/vid.height;
|
|
|
|
|
|
|
|
// fudge around because of frac screen scale
|
|
|
|
if (x > 0)
|
|
|
|
x--;
|
|
|
|
if (x2 < glwidth)
|
|
|
|
x2++;
|
|
|
|
if (y2 < 0)
|
|
|
|
y2--;
|
|
|
|
if (y < glheight)
|
|
|
|
y++;
|
|
|
|
|
|
|
|
w = x2 - x;
|
|
|
|
h = y - y2;
|
|
|
|
|
|
|
|
if (envmap)
|
|
|
|
{
|
|
|
|
x = y2 = 0;
|
|
|
|
w = h = 256;
|
|
|
|
}
|
|
|
|
|
|
|
|
glViewport (glx + x, gly + y2, w, h);
|
|
|
|
screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
|
|
|
|
// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI;
|
2000-05-16 04:47:41 +00:00
|
|
|
// yfov = (2.0 * tan (scr_fov->value/360*M_PI)) / screenaspect;
|
|
|
|
// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*(scr_fov->value*2)/M_PI;
|
2000-05-10 11:29:38 +00:00
|
|
|
// MYgluPerspective (yfov, screenaspect, 4, 4096);
|
|
|
|
MYgluPerspective (r_refdef.fov_y, screenaspect, 4, 4096);
|
|
|
|
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity ();
|
|
|
|
|
|
|
|
glRotatef (-90, 1, 0, 0); // put Z going up
|
|
|
|
glRotatef (90, 0, 0, 1); // put Z going up
|
|
|
|
glRotatef (-r_refdef.viewangles[2], 1, 0, 0);
|
|
|
|
glRotatef (-r_refdef.viewangles[0], 0, 1, 0);
|
|
|
|
glRotatef (-r_refdef.viewangles[1], 0, 0, 1);
|
|
|
|
glTranslatef (-r_refdef.vieworg[0], -r_refdef.vieworg[1], -r_refdef.vieworg[2]);
|
|
|
|
|
|
|
|
glGetFloatv (GL_MODELVIEW_MATRIX, r_world_matrix);
|
|
|
|
|
|
|
|
//
|
|
|
|
// set drawing parms
|
|
|
|
//
|
2000-05-16 04:47:41 +00:00
|
|
|
if (gl_cull->value)
|
2000-06-07 07:23:23 +00:00
|
|
|
glEnable (GL_CULL_FACE);
|
2000-05-10 11:29:38 +00:00
|
|
|
else
|
2000-06-07 07:23:23 +00:00
|
|
|
glDisable (GL_CULL_FACE);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
2000-06-07 07:23:23 +00:00
|
|
|
glDisable (GL_ALPHA_TEST);
|
|
|
|
glAlphaFunc (GL_GREATER, 0.5);
|
|
|
|
glEnable (GL_DEPTH_TEST);
|
2000-09-28 07:56:00 +00:00
|
|
|
if (gl_smooth->value)
|
|
|
|
glShadeModel (GL_SMOOTH);
|
|
|
|
else
|
|
|
|
glShadeModel (GL_FLAT);
|
2000-05-10 11:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
R_RenderScene
|
|
|
|
|
|
|
|
r_refdef must be set before the first call
|
|
|
|
================
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_RenderScene (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
|
|
|
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 ();
|
2000-06-19 22:15:18 +00:00
|
|
|
R_UpdateFires ();
|
2000-05-10 11:29:38 +00:00
|
|
|
R_DrawParticles ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_Clear
|
|
|
|
=============
|
|
|
|
*/
|
2000-08-16 09:26:22 +00:00
|
|
|
static void R_Clear (void)
|
2000-05-10 11:29:38 +00:00
|
|
|
{
|
2000-06-17 12:37:28 +00:00
|
|
|
if (gl_clear->value)
|
|
|
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
2000-05-10 11:29:38 +00:00
|
|
|
else
|
2000-06-17 12:37:28 +00:00
|
|
|
glClear (GL_DEPTH_BUFFER_BIT);
|
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 1;
|
|
|
|
glDepthFunc (GL_LEQUAL);
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
glDepthRange (gldepthmin, gldepthmax);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
R_RenderView
|
|
|
|
|
|
|
|
r_refdef must be set before the first call
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void R_RenderView (void)
|
|
|
|
{
|
2000-05-16 04:47:41 +00:00
|
|
|
if (r_norefresh->value)
|
2000-05-10 11:29:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!r_worldentity.model || !cl.worldmodel)
|
|
|
|
Sys_Error ("R_RenderView: NULL worldmodel");
|
|
|
|
|
2000-06-04 11:20:51 +00:00
|
|
|
// glFinish ();
|
2000-05-10 11:29:38 +00:00
|
|
|
|
|
|
|
R_Clear ();
|
|
|
|
|
|
|
|
// render normal view
|
|
|
|
R_RenderScene ();
|
|
|
|
R_DrawViewModel ();
|
|
|
|
R_DrawWaterSurfaces ();
|
|
|
|
}
|