2009-03-05 09:07:55 +00:00
|
|
|
/*
|
2010-10-22 07:49:17 +00:00
|
|
|
* Copyright (C) 1997-2001 Id Software, Inc.
|
|
|
|
*
|
2010-10-23 06:58:56 +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.
|
2010-10-22 07:49:17 +00:00
|
|
|
*
|
2010-10-23 06:58:56 +00:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
2010-10-22 07:49:17 +00:00
|
|
|
* 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
|
2010-10-23 06:58:56 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
2010-10-22 07:49:17 +00:00
|
|
|
*
|
2010-10-23 06:58:56 +00:00
|
|
|
* =======================================================================
|
|
|
|
*
|
|
|
|
* Refresher setup and main part of the frame generation
|
|
|
|
*
|
|
|
|
* =======================================================================
|
2010-10-25 12:33:55 +00:00
|
|
|
*/
|
2009-03-05 12:42:43 +00:00
|
|
|
|
2009-03-05 11:03:08 +00:00
|
|
|
#include "header/local.h"
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
#define NUM_BEAM_SEGS 6
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
viddef_t vid;
|
2012-07-21 12:09:45 +00:00
|
|
|
model_t *r_worldmodel;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
float gldepthmin, gldepthmax;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
glconfig_t gl_config;
|
2010-10-22 07:49:17 +00:00
|
|
|
glstate_t gl_state;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
image_t *r_notexture; /* use for bad textures */
|
|
|
|
image_t *r_particletexture; /* little dot for particles */
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
entity_t *currententity;
|
|
|
|
model_t *currentmodel;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
cplane_t frustum[4];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
int r_visframecount; /* bumped when going to a new PVS */
|
|
|
|
int r_framecount; /* used for dlight push checking */
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
int c_brush_polys, c_alias_polys;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
float v_blend[4]; /* final blending color */
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
void R_Strings(void);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* view origin */
|
|
|
|
vec3_t vup;
|
|
|
|
vec3_t vpn;
|
|
|
|
vec3_t vright;
|
|
|
|
vec3_t r_origin;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
float r_world_matrix[16];
|
|
|
|
float r_base_world_matrix[16];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* screen size info */
|
|
|
|
refdef_t r_newrefdef;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
|
|
|
|
extern qboolean have_stencil;
|
2012-07-21 12:09:45 +00:00
|
|
|
unsigned r_rawpalette[256];
|
|
|
|
|
|
|
|
cvar_t *gl_norefresh;
|
|
|
|
cvar_t *gl_drawentities;
|
|
|
|
cvar_t *gl_drawworld;
|
|
|
|
cvar_t *gl_speeds;
|
|
|
|
cvar_t *gl_fullbright;
|
|
|
|
cvar_t *gl_novis;
|
|
|
|
cvar_t *gl_nocull;
|
|
|
|
cvar_t *gl_lerpmodels;
|
|
|
|
cvar_t *gl_lefthand;
|
|
|
|
cvar_t *gl_farsee;
|
|
|
|
|
|
|
|
cvar_t *gl_lightlevel;
|
|
|
|
cvar_t *gl_overbrightbits;
|
|
|
|
|
|
|
|
cvar_t *gl_nosubimage;
|
|
|
|
cvar_t *gl_allow_software;
|
|
|
|
|
|
|
|
cvar_t *gl_vertex_arrays;
|
|
|
|
|
|
|
|
cvar_t *gl_particle_min_size;
|
|
|
|
cvar_t *gl_particle_max_size;
|
|
|
|
cvar_t *gl_particle_size;
|
|
|
|
cvar_t *gl_particle_att_a;
|
|
|
|
cvar_t *gl_particle_att_b;
|
|
|
|
cvar_t *gl_particle_att_c;
|
|
|
|
|
|
|
|
cvar_t *gl_ext_swapinterval;
|
|
|
|
cvar_t *gl_ext_palettedtexture;
|
|
|
|
cvar_t *gl_ext_multitexture;
|
|
|
|
cvar_t *gl_ext_pointparameters;
|
|
|
|
cvar_t *gl_ext_compiled_vertex_array;
|
|
|
|
cvar_t *gl_ext_mtexcombine;
|
|
|
|
|
|
|
|
cvar_t *gl_bitdepth;
|
|
|
|
cvar_t *gl_drawbuffer;
|
|
|
|
cvar_t *gl_lightmap;
|
|
|
|
cvar_t *gl_shadows;
|
|
|
|
cvar_t *gl_stencilshadow;
|
|
|
|
cvar_t *gl_mode;
|
|
|
|
|
|
|
|
cvar_t *gl_customwidth;
|
|
|
|
cvar_t *gl_customheight;
|
2010-01-08 14:19:29 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
cvar_t *gl_retexturing;
|
2012-03-12 09:31:33 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
cvar_t *gl_dynamic;
|
|
|
|
cvar_t *gl_modulate;
|
|
|
|
cvar_t *gl_nobind;
|
|
|
|
cvar_t *gl_round_down;
|
|
|
|
cvar_t *gl_picmip;
|
|
|
|
cvar_t *gl_skymip;
|
|
|
|
cvar_t *gl_showtris;
|
|
|
|
cvar_t *gl_ztrick;
|
2013-03-16 15:47:57 +00:00
|
|
|
cvar_t *gl_zfix;
|
2012-07-21 12:09:45 +00:00
|
|
|
cvar_t *gl_finish;
|
|
|
|
cvar_t *gl_clear;
|
|
|
|
cvar_t *gl_cull;
|
|
|
|
cvar_t *gl_polyblend;
|
|
|
|
cvar_t *gl_flashblend;
|
|
|
|
cvar_t *gl_playermip;
|
|
|
|
cvar_t *gl_saturatelighting;
|
|
|
|
cvar_t *gl_swapinterval;
|
|
|
|
cvar_t *gl_texturemode;
|
|
|
|
cvar_t *gl_texturealphamode;
|
|
|
|
cvar_t *gl_texturesolidmode;
|
|
|
|
cvar_t *gl_anisotropic;
|
|
|
|
cvar_t *gl_anisotropic_avail;
|
|
|
|
cvar_t *gl_lockpvs;
|
2014-01-26 08:53:10 +00:00
|
|
|
cvar_t *gl_msaa_samples;
|
2012-07-21 12:09:45 +00:00
|
|
|
|
|
|
|
cvar_t *vid_fullscreen;
|
|
|
|
cvar_t *vid_gamma;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2016-04-07 15:01:09 +00:00
|
|
|
cvar_t *gl_stereo;
|
|
|
|
cvar_t *gl_stereo_separation;
|
|
|
|
cvar_t *gl_stereo_anaglyph_colors;
|
|
|
|
cvar_t *gl_stereo_convergence;
|
2016-03-31 20:31:07 +00:00
|
|
|
|
2009-03-05 09:07:55 +00:00
|
|
|
/*
|
2010-10-22 07:49:17 +00:00
|
|
|
* Returns true if the box is completely outside the frustom
|
|
|
|
*/
|
|
|
|
qboolean
|
2012-07-21 12:09:45 +00:00
|
|
|
R_CullBox(vec3_t mins, vec3_t maxs)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
int i;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_nocull->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
return false;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (BOX_ON_PLANE_SIDE(mins, maxs, &frustum[i]) == 2)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
return true;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
return false;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_RotateForEntity(entity_t *e)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glTranslatef(e->origin[0], e->origin[1], e->origin[2]);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glRotatef(e->angles[1], 0, 0, 1);
|
|
|
|
glRotatef(-e->angles[0], 0, 1, 0);
|
|
|
|
glRotatef(-e->angles[2], 1, 0, 0);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawSpriteModel(entity_t *e)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
float alpha = 1.0F;
|
2014-06-14 08:07:33 +00:00
|
|
|
vec3_t point[4];
|
2010-10-22 07:49:17 +00:00
|
|
|
dsprframe_t *frame;
|
2012-07-21 12:09:45 +00:00
|
|
|
float *up, *right;
|
|
|
|
dsprite_t *psprite;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
/* don't even bother culling, because it's just
|
|
|
|
a single polygon without a surface cache */
|
|
|
|
psprite = (dsprite_t *)currentmodel->extradata;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
e->frame %= psprite->numframes;
|
2012-07-21 12:09:45 +00:00
|
|
|
frame = &psprite->frames[e->frame];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
/* normal sprite */
|
|
|
|
up = vup;
|
|
|
|
right = vright;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (e->flags & RF_TRANSLUCENT)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
alpha = e->alpha;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (alpha != 1.0F)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_BLEND);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glColor4f(1, 1, 1, alpha);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(currentmodel->skins[e->frame]->texnum);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TexEnv(GL_MODULATE);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (alpha == 1.0)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_ALPHA_TEST);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_ALPHA_TEST);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat tex[] = {
|
|
|
|
0, 1,
|
|
|
|
0, 0,
|
|
|
|
1, 0,
|
|
|
|
1, 1
|
|
|
|
};
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
VectorMA( e->origin, -frame->origin_y, up, point[0] );
|
|
|
|
VectorMA( point[0], -frame->origin_x, right, point[0] );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
VectorMA( e->origin, frame->height - frame->origin_y, up, point[1] );
|
|
|
|
VectorMA( point[1], -frame->origin_x, right, point[1] );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
VectorMA( e->origin, frame->height - frame->origin_y, up, point[2] );
|
|
|
|
VectorMA( point[2], frame->width - frame->origin_x, right, point[2] );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
VectorMA( e->origin, -frame->origin_y, up, point[3] );
|
|
|
|
VectorMA( point[3], frame->width - frame->origin_x, right, point[3] );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, point );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_ALPHA_TEST);
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TexEnv(GL_REPLACE);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (alpha != 1.0F)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_BLEND);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glColor4f(1, 1, 1, 1);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawNullModel(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
vec3_t shadelight;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (currententity->flags & RF_FULLBRIGHT)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
shadelight[0] = shadelight[1] = shadelight[2] = 1.0F;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_LightPoint(currententity->origin, shadelight);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glPushMatrix();
|
2012-07-21 12:09:45 +00:00
|
|
|
R_RotateForEntity(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
2016-08-04 18:48:05 +00:00
|
|
|
glColor4f( shadelight[0], shadelight[1], shadelight[2], 1 );
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat vtxA[] = {
|
|
|
|
0, 0, -16,
|
|
|
|
16 * cos( 0 * M_PI / 2 ), 16 * sin( 0 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 1 * M_PI / 2 ), 16 * sin( 1 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 2 * M_PI / 2 ), 16 * sin( 2 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 3 * M_PI / 2 ), 16 * sin( 3 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 4 * M_PI / 2 ), 16 * sin( 4 * M_PI / 2 ), 0
|
|
|
|
};
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, vtxA );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 6 );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
GLfloat vtxB[] = {
|
|
|
|
0, 0, 16,
|
|
|
|
16 * cos( 4 * M_PI / 2 ), 16 * sin( 4 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 3 * M_PI / 2 ), 16 * sin( 3 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 2 * M_PI / 2 ), 16 * sin( 2 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 1 * M_PI / 2 ), 16 * sin( 1 * M_PI / 2 ), 0,
|
|
|
|
16 * cos( 0 * M_PI / 2 ), 16 * sin( 0 * M_PI / 2 ), 0
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, vtxB );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 6 );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2016-08-04 18:48:05 +00:00
|
|
|
glColor4f(1, 1, 1, 1);
|
2013-07-27 06:44:07 +00:00
|
|
|
glPopMatrix();
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawEntitiesOnList(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
int i;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!gl_drawentities->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* draw non-transparent first */
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < r_newrefdef.num_entities; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
currententity = &r_newrefdef.entities[i];
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (currententity->flags & RF_TRANSLUCENT)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
|
|
|
continue; /* solid */
|
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (currententity->flags & RF_BEAM)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawBeam(currententity);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentmodel = currententity->model;
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!currentmodel)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
R_DrawNullModel();
|
2009-03-05 09:07:55 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
switch (currentmodel->type)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
case mod_alias:
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawAliasModel(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
|
|
|
case mod_brush:
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawBrushModel(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
|
|
|
case mod_sprite:
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawSpriteModel(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Error(ERR_DROP, "Bad modeltype");
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-25 12:33:55 +00:00
|
|
|
/* draw transparent entities
|
2012-07-21 12:09:45 +00:00
|
|
|
we could sort these if it ever
|
|
|
|
becomes a problem... */
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthMask(0);
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < r_newrefdef.num_entities; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
currententity = &r_newrefdef.entities[i];
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!(currententity->flags & RF_TRANSLUCENT))
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
|
|
|
continue; /* solid */
|
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (currententity->flags & RF_BEAM)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawBeam(currententity);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentmodel = currententity->model;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!currentmodel)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
R_DrawNullModel();
|
2009-03-05 09:07:55 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
switch (currentmodel->type)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
case mod_alias:
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawAliasModel(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
|
|
|
case mod_brush:
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawBrushModel(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
|
|
|
case mod_sprite:
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawSpriteModel(currententity);
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Error(ERR_DROP, "Bad modeltype");
|
2010-10-22 07:49:17 +00:00
|
|
|
break;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthMask(1); /* back to writing */
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawParticles2(int num_particles, const particle_t particles[],
|
|
|
|
const unsigned colortable[768])
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
const particle_t *p;
|
2010-10-22 07:49:17 +00:00
|
|
|
int i;
|
|
|
|
vec3_t up, right;
|
|
|
|
float scale;
|
2012-07-21 12:09:45 +00:00
|
|
|
byte color[4];
|
2014-06-14 08:07:33 +00:00
|
|
|
|
|
|
|
GLfloat vtx[3*num_particles*3];
|
|
|
|
GLfloat tex[2*num_particles*3];
|
|
|
|
GLfloat clr[4*num_particles*3];
|
|
|
|
unsigned int index_vtx = 0;
|
|
|
|
unsigned int index_tex = 0;
|
|
|
|
unsigned int index_clr = 0;
|
|
|
|
unsigned int j;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Bind(r_particletexture->texnum);
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthMask(GL_FALSE); /* no z buffering */
|
|
|
|
glEnable(GL_BLEND);
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TexEnv(GL_MODULATE);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
VectorScale( vup, 1.5, up );
|
|
|
|
VectorScale( vright, 1.5, right );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
for ( p = particles, i = 0; i < num_particles; i++, p++ )
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
/* hack a scale up to keep particles from disapearing */
|
2014-06-14 08:07:33 +00:00
|
|
|
scale = ( p->origin [ 0 ] - r_origin [ 0 ] ) * vpn [ 0 ] +
|
|
|
|
( p->origin [ 1 ] - r_origin [ 1 ] ) * vpn [ 1 ] +
|
|
|
|
( p->origin [ 2 ] - r_origin [ 2 ] ) * vpn [ 2 ];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
if ( scale < 20 )
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
scale = 1;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
scale = 1 + scale * 0.004;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
*(int *) color = colortable [ p->color ];
|
|
|
|
|
|
|
|
for (j=0; j<3; j++) // Copy the color for each point
|
|
|
|
{
|
|
|
|
clr[index_clr++] = color[0]/255.0f;
|
|
|
|
clr[index_clr++] = color[1]/255.0f;
|
|
|
|
clr[index_clr++] = color[2]/255.0f;
|
|
|
|
clr[index_clr++] = p->alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
// point 0
|
|
|
|
tex[index_tex++] = 0.0625f;
|
|
|
|
tex[index_tex++] = 0.0625f;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
vtx[index_vtx++] = p->origin[0];
|
|
|
|
vtx[index_vtx++] = p->origin[1];
|
|
|
|
vtx[index_vtx++] = p->origin[2];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
// point 1
|
|
|
|
tex[index_tex++] = 1.0625f;
|
|
|
|
tex[index_tex++] = 0.0625f;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
vtx[index_vtx++] = p->origin [ 0 ] + up [ 0 ] * scale;
|
|
|
|
vtx[index_vtx++] = p->origin [ 1 ] + up [ 1 ] * scale;
|
|
|
|
vtx[index_vtx++] = p->origin [ 2 ] + up [ 2 ] * scale;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
// point 2
|
|
|
|
tex[index_tex++] = 0.0625f;
|
|
|
|
tex[index_tex++] = 1.0625f;
|
|
|
|
|
|
|
|
vtx[index_vtx++] = p->origin [ 0 ] + right [ 0 ] * scale;
|
|
|
|
vtx[index_vtx++] = p->origin [ 1 ] + right [ 1 ] * scale;
|
|
|
|
vtx[index_vtx++] = p->origin [ 2 ] + right [ 2 ] * scale;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
glEnableClientState( GL_COLOR_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, vtx );
|
|
|
|
glTexCoordPointer( 2, GL_FLOAT, 0, tex );
|
|
|
|
glColorPointer( 4, GL_FLOAT, 0, clr );
|
|
|
|
glDrawArrays( GL_TRIANGLES, 0, num_particles*3 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
|
|
|
glDisableClientState( GL_COLOR_ARRAY );
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glColor4f(1, 1, 1, 1);
|
|
|
|
glDepthMask(1); /* back to normal Z buffering */
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TexEnv(GL_REPLACE);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawParticles(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2016-04-01 12:11:54 +00:00
|
|
|
qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation);
|
|
|
|
qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation);
|
|
|
|
|
|
|
|
if (gl_ext_pointparameters->value && qglPointParameterfEXT && !(stereo_split_tb || stereo_split_lr))
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2012-07-21 12:09:45 +00:00
|
|
|
unsigned char color[4];
|
2009-03-05 09:07:55 +00:00
|
|
|
const particle_t *p;
|
2014-06-14 08:07:33 +00:00
|
|
|
|
|
|
|
GLfloat vtx[3*r_newrefdef.num_particles];
|
|
|
|
GLfloat clr[4*r_newrefdef.num_particles];
|
|
|
|
unsigned int index_vtx = 0;
|
|
|
|
unsigned int index_clr = 0;
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthMask(GL_FALSE);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2016-04-03 21:25:20 +00:00
|
|
|
glPointSize(LittleFloat(gl_particle_size->value));
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
for ( i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++ )
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2014-06-14 08:07:33 +00:00
|
|
|
*(int *) color = d_8to24table [ p->color & 0xFF ];
|
|
|
|
clr[index_clr++] = color[0]/255.0f;
|
|
|
|
clr[index_clr++] = color[1]/255.0f;
|
|
|
|
clr[index_clr++] = color[2]/255.0f;
|
|
|
|
clr[index_clr++] = p->alpha;
|
|
|
|
|
|
|
|
vtx[index_vtx++] = p->origin[0];
|
|
|
|
vtx[index_vtx++] = p->origin[1];
|
|
|
|
vtx[index_vtx++] = p->origin[2];
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glEnableClientState( GL_COLOR_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, vtx );
|
|
|
|
glColorPointer( 4, GL_FLOAT, 0, clr );
|
|
|
|
glDrawArrays( GL_POINTS, 0, r_newrefdef.num_particles );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
|
|
|
glDisableClientState( GL_COLOR_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_BLEND);
|
2014-06-14 08:07:33 +00:00
|
|
|
glColor4f( 1, 1, 1, 1 );
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthMask(GL_TRUE);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawParticles2(r_newrefdef.num_particles,
|
|
|
|
r_newrefdef.particles, d_8to24table);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_PolyBlend(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!gl_polyblend->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!v_blend[3])
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_ALPHA_TEST);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glLoadIdentity();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glRotatef(-90, 1, 0, 0); /* put Z going up */
|
|
|
|
glRotatef(90, 0, 0, 1); /* put Z going up */
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glColor4f( v_blend[0], v_blend[1], v_blend[2], v_blend[3] );
|
|
|
|
|
|
|
|
GLfloat vtx[] = {
|
|
|
|
10, 100, 100,
|
|
|
|
10, -100, 100,
|
|
|
|
10, -100, -100,
|
|
|
|
10, 100, -100
|
|
|
|
};
|
|
|
|
|
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, vtx );
|
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glEnable(GL_ALPHA_TEST);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glColor4f(1, 1, 1, 1);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
int
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SignbitsForPlane(cplane_t *out)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
int bits, j;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* for fast box on planeside test */
|
2009-03-05 09:07:55 +00:00
|
|
|
bits = 0;
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (j = 0; j < 3; j++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (out->normal[j] < 0)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
|
|
|
bits |= 1 << j;
|
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
return bits;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetFrustum(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* rotate VPN right by FOV_X/2 degrees */
|
2012-07-21 12:09:45 +00:00
|
|
|
RotatePointAroundVector(frustum[0].normal, vup, vpn,
|
|
|
|
-(90 - r_newrefdef.fov_x / 2));
|
2010-10-22 07:49:17 +00:00
|
|
|
/* rotate VPN left by FOV_X/2 degrees */
|
2012-07-21 12:09:45 +00:00
|
|
|
RotatePointAroundVector(frustum[1].normal,
|
|
|
|
vup, vpn, 90 - r_newrefdef.fov_x / 2);
|
2010-10-22 07:49:17 +00:00
|
|
|
/* rotate VPN up by FOV_X/2 degrees */
|
2012-07-21 12:09:45 +00:00
|
|
|
RotatePointAroundVector(frustum[2].normal,
|
|
|
|
vright, vpn, 90 - r_newrefdef.fov_y / 2);
|
2010-10-22 07:49:17 +00:00
|
|
|
/* rotate VPN down by FOV_X/2 degrees */
|
2012-07-21 12:09:45 +00:00
|
|
|
RotatePointAroundVector(frustum[3].normal, vright, vpn,
|
|
|
|
-(90 - r_newrefdef.fov_y / 2));
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
frustum[i].type = PLANE_ANYZ;
|
|
|
|
frustum[i].dist = DotProduct(r_origin, frustum[i].normal);
|
|
|
|
frustum[i].signbits = R_SignbitsForPlane(&frustum[i]);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetupFrame(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
int i;
|
2010-10-22 07:49:17 +00:00
|
|
|
mleaf_t *leaf;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
r_framecount++;
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* build the transformation matrix for the given view angles */
|
2012-07-21 12:09:45 +00:00
|
|
|
VectorCopy(r_newrefdef.vieworg, r_origin);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
AngleVectors(r_newrefdef.viewangles, vpn, vright, vup);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* current viewcluster */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!(r_newrefdef.rdflags & RDF_NOWORLDMODEL))
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
r_oldviewcluster = r_viewcluster;
|
|
|
|
r_oldviewcluster2 = r_viewcluster2;
|
2012-07-21 12:09:45 +00:00
|
|
|
leaf = Mod_PointInLeaf(r_origin, r_worldmodel);
|
2009-03-05 09:07:55 +00:00
|
|
|
r_viewcluster = r_viewcluster2 = leaf->cluster;
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* check above and below so crossing solid water doesn't draw wrong */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!leaf->contents)
|
2013-04-29 21:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
/* look down a bit */
|
2010-10-22 07:49:17 +00:00
|
|
|
vec3_t temp;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
VectorCopy(r_origin, temp);
|
|
|
|
temp[2] -= 16;
|
|
|
|
leaf = Mod_PointInLeaf(temp, r_worldmodel);
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!(leaf->contents & CONTENTS_SOLID) &&
|
|
|
|
(leaf->cluster != r_viewcluster2))
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
r_viewcluster2 = leaf->cluster;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
|
|
|
/* look up a bit */
|
|
|
|
vec3_t temp;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
VectorCopy(r_origin, temp);
|
|
|
|
temp[2] += 16;
|
|
|
|
leaf = Mod_PointInLeaf(temp, r_worldmodel);
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!(leaf->contents & CONTENTS_SOLID) &&
|
|
|
|
(leaf->cluster != r_viewcluster2))
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
r_viewcluster2 = leaf->cluster;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
v_blend[i] = r_newrefdef.blend[i];
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
c_brush_polys = 0;
|
|
|
|
c_alias_polys = 0;
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* clear out the portion of the screen that the NOWORLDMODEL defines */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (r_newrefdef.rdflags & RDF_NOWORLDMODEL)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_SCISSOR_TEST);
|
|
|
|
glClearColor(0.3, 0.3, 0.3, 1);
|
|
|
|
glScissor(r_newrefdef.x,
|
2012-07-21 12:09:45 +00:00
|
|
|
vid.height - r_newrefdef.height - r_newrefdef.y,
|
|
|
|
r_newrefdef.width, r_newrefdef.height);
|
2013-07-27 06:44:07 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
glClearColor(1, 0, 0.5, 0.5);
|
|
|
|
glDisable(GL_SCISSOR_TEST);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_MYgluPerspective(GLdouble fovy, GLdouble aspect,
|
|
|
|
GLdouble zNear, GLdouble zFar)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
GLdouble xmin, xmax, ymin, ymax;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
ymax = zNear * tan(fovy * M_PI / 360.0);
|
2010-10-22 07:49:17 +00:00
|
|
|
ymin = -ymax;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
xmin = ymin * aspect;
|
|
|
|
xmax = ymax * aspect;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2016-04-07 15:01:09 +00:00
|
|
|
xmin += - gl_stereo_convergence->value * (2 * gl_state.camera_separation) / zNear;
|
|
|
|
xmax += - gl_stereo_convergence->value * (2 * gl_state.camera_separation) / zNear;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetupGL(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
float screenaspect;
|
|
|
|
int x, x2, y2, y, w, h;
|
|
|
|
|
|
|
|
/* set up viewport */
|
2012-07-21 12:09:45 +00:00
|
|
|
x = floor(r_newrefdef.x * vid.width / vid.width);
|
|
|
|
x2 = ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
|
|
|
|
y = floor(vid.height - r_newrefdef.y * vid.height / vid.height);
|
|
|
|
y2 = ceil(vid.height -
|
|
|
|
(r_newrefdef.y + r_newrefdef.height) * vid.height / vid.height);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
w = x2 - x;
|
|
|
|
h = y - y2;
|
|
|
|
|
2016-04-04 16:33:18 +00:00
|
|
|
qboolean drawing_left_eye = gl_state.camera_separation < 0;
|
2016-04-01 12:11:54 +00:00
|
|
|
qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation);
|
|
|
|
qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation);
|
|
|
|
|
|
|
|
if(stereo_split_lr) {
|
|
|
|
w = w / 2;
|
2016-04-04 16:33:18 +00:00
|
|
|
x = drawing_left_eye ? (x / 2) : (x + vid.width) / 2;
|
2016-04-01 12:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(stereo_split_tb) {
|
|
|
|
h = h / 2;
|
2016-04-04 16:33:18 +00:00
|
|
|
y2 = drawing_left_eye ? (y2 + vid.height) / 2 : (y2 / 2);
|
2016-04-01 12:11:54 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glViewport(x, y2, w, h);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* set up projection matrix */
|
2012-07-21 12:09:45 +00:00
|
|
|
screenaspect = (float)r_newrefdef.width / r_newrefdef.height;
|
2013-07-27 06:44:07 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
2012-07-21 12:09:45 +00:00
|
|
|
|
|
|
|
if (gl_farsee->value == 0)
|
|
|
|
{
|
|
|
|
R_MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 4096);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
R_MYgluPerspective(r_newrefdef.fov_y, screenaspect, 4, 8192);
|
2012-03-08 11:24:45 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glCullFace(GL_FRONT);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glRotatef(-90, 1, 0, 0); /* put Z going up */
|
|
|
|
glRotatef(90, 0, 0, 1); /* put Z going up */
|
|
|
|
glRotatef(-r_newrefdef.viewangles[2], 1, 0, 0);
|
|
|
|
glRotatef(-r_newrefdef.viewangles[0], 0, 1, 0);
|
|
|
|
glRotatef(-r_newrefdef.viewangles[1], 0, 0, 1);
|
|
|
|
glTranslatef(-r_newrefdef.vieworg[0], -r_newrefdef.vieworg[1],
|
2012-07-21 12:09:45 +00:00
|
|
|
-r_newrefdef.vieworg[2]);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glGetFloatv(GL_MODELVIEW_MATRIX, r_world_matrix);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* set drawing parms */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_cull->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_CULL_FACE);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_CULL_FACE);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDisable(GL_ALPHA_TEST);
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Clear(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2016-03-31 20:31:07 +00:00
|
|
|
// Check whether the stencil buffer needs clearing, and do so if need be.
|
|
|
|
GLbitfield stencilFlags = 0;
|
|
|
|
if (gl_state.stereo_mode >= STEREO_MODE_ROW_INTERLEAVED && gl_state.stereo_mode <= STEREO_MODE_PIXEL_INTERLEAVED) {
|
|
|
|
glClearStencil(0);
|
|
|
|
stencilFlags |= GL_STENCIL_BUFFER_BIT;
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_ztrick->value)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
static int trickframe;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_clear->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2016-03-31 20:31:07 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | stencilFlags);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
trickframe++;
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (trickframe & 1)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 0.49999;
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthFunc(GL_LEQUAL);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gldepthmin = 1;
|
|
|
|
gldepthmax = 0.5;
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthFunc(GL_GEQUAL);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_clear->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2016-03-31 20:31:07 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | stencilFlags | GL_DEPTH_BUFFER_BIT);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2016-03-31 20:31:07 +00:00
|
|
|
glClear(GL_DEPTH_BUFFER_BIT | stencilFlags);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 09:07:55 +00:00
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 1;
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthFunc(GL_LEQUAL);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDepthRange(gldepthmin, gldepthmax);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-04-07 17:05:11 +00:00
|
|
|
if (gl_zfix->value)
|
|
|
|
{
|
|
|
|
if (gldepthmax > gldepthmin)
|
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glPolygonOffset(0.05, 1);
|
2013-04-07 17:05:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glPolygonOffset(-0.05, -1);
|
2013-04-07 17:05:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-05 09:07:55 +00:00
|
|
|
/* stencilbuffer shadows */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_shadows->value && have_stencil && gl_stencilshadow->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glClearStencil(1);
|
|
|
|
glClear(GL_STENCIL_BUFFER_BIT);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Flash(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
R_PolyBlend();
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 14:57:32 +00:00
|
|
|
void
|
|
|
|
R_SetGL2D(void)
|
|
|
|
{
|
|
|
|
int x, w, y, h;
|
|
|
|
/* set 2D virtual screen size */
|
|
|
|
qboolean drawing_left_eye = gl_state.camera_separation < 0;
|
|
|
|
qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation);
|
|
|
|
qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation);
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
w = vid.width;
|
|
|
|
y = 0;
|
|
|
|
h = vid.height;
|
|
|
|
|
|
|
|
if(stereo_split_lr) {
|
|
|
|
w = w / 2;
|
|
|
|
x = drawing_left_eye ? 0 : w;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(stereo_split_tb) {
|
|
|
|
h = h / 2;
|
|
|
|
y = drawing_left_eye ? h : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
glViewport(x, y, w, h);
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
glOrtho(0, vid.width, vid.height, 0, -99999, 99999);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glEnable(GL_ALPHA_TEST);
|
|
|
|
glColor4f(1, 1, 1, 1);
|
|
|
|
}
|
|
|
|
|
2009-03-05 09:07:55 +00:00
|
|
|
/*
|
2010-10-22 07:49:17 +00:00
|
|
|
* r_newrefdef must be set before the first call
|
|
|
|
*/
|
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_RenderView(refdef_t *fd)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2016-03-31 20:31:07 +00:00
|
|
|
if ((gl_state.stereo_mode != STEREO_MODE_NONE) && gl_state.camera_separation) {
|
|
|
|
|
2016-04-04 16:33:18 +00:00
|
|
|
qboolean drawing_left_eye = gl_state.camera_separation < 0;
|
2016-03-31 20:31:07 +00:00
|
|
|
switch (gl_state.stereo_mode) {
|
|
|
|
case STEREO_MODE_ANAGLYPH:
|
|
|
|
{
|
|
|
|
|
|
|
|
// Work out the colour for each eye.
|
|
|
|
int anaglyph_colours[] = { 0x4, 0x3 }; // Left = red, right = cyan.
|
2016-04-07 14:57:32 +00:00
|
|
|
|
2016-04-07 15:01:09 +00:00
|
|
|
if (strlen(gl_stereo_anaglyph_colors->string) == 2) {
|
2016-03-31 20:31:07 +00:00
|
|
|
int eye, colour, missing_bits;
|
|
|
|
// Decode the colour name from its character.
|
|
|
|
for (eye = 0; eye < 2; ++eye) {
|
|
|
|
colour = 0;
|
2016-04-07 15:01:09 +00:00
|
|
|
switch (toupper(gl_stereo_anaglyph_colors->string[eye])) {
|
2016-03-31 20:31:07 +00:00
|
|
|
case 'B': ++colour; // 001 Blue
|
|
|
|
case 'G': ++colour; // 010 Green
|
|
|
|
case 'C': ++colour; // 011 Cyan
|
|
|
|
case 'R': ++colour; // 100 Red
|
|
|
|
case 'M': ++colour; // 101 Magenta
|
|
|
|
case 'Y': ++colour; // 110 Yellow
|
|
|
|
anaglyph_colours[eye] = colour;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Fill in any missing bits.
|
|
|
|
missing_bits = ~(anaglyph_colours[0] | anaglyph_colours[1]) & 0x3;
|
|
|
|
for (eye = 0; eye < 2; ++eye) {
|
|
|
|
anaglyph_colours[eye] |= missing_bits;
|
|
|
|
}
|
|
|
|
}
|
2016-04-07 14:57:32 +00:00
|
|
|
|
2016-03-31 20:31:07 +00:00
|
|
|
// Set the current colour.
|
|
|
|
glColorMask(
|
|
|
|
!!(anaglyph_colours[drawing_left_eye] & 0x4),
|
|
|
|
!!(anaglyph_colours[drawing_left_eye] & 0x2),
|
|
|
|
!!(anaglyph_colours[drawing_left_eye] & 0x1),
|
|
|
|
GL_TRUE
|
2016-04-07 14:57:32 +00:00
|
|
|
);
|
2016-03-31 20:31:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STEREO_MODE_ROW_INTERLEAVED:
|
|
|
|
case STEREO_MODE_COLUMN_INTERLEAVED:
|
|
|
|
case STEREO_MODE_PIXEL_INTERLEAVED:
|
|
|
|
{
|
|
|
|
qboolean flip_eyes = true;
|
|
|
|
int client_x, client_y;
|
|
|
|
|
|
|
|
//GLimp_GetClientAreaOffset(&client_x, &client_y);
|
|
|
|
client_x = 0;
|
|
|
|
client_y = 0;
|
|
|
|
|
|
|
|
R_SetGL2D();
|
|
|
|
|
|
|
|
glEnable(GL_STENCIL_TEST);
|
|
|
|
glStencilMask(GL_TRUE);
|
|
|
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
|
|
|
|
|
|
glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
|
|
|
|
glStencilFunc(GL_NEVER, 0, 1);
|
|
|
|
|
|
|
|
glBegin(GL_QUADS);
|
|
|
|
{
|
|
|
|
glVertex2i(0, 0);
|
|
|
|
glVertex2i(vid.width, 0);
|
|
|
|
glVertex2i(vid.width, vid.height);
|
|
|
|
glVertex2i(0, vid.height);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glStencilOp(GL_INVERT, GL_KEEP, GL_KEEP);
|
|
|
|
glStencilFunc(GL_NEVER, 1, 1);
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
{
|
|
|
|
if (gl_state.stereo_mode == STEREO_MODE_ROW_INTERLEAVED || gl_state.stereo_mode == STEREO_MODE_PIXEL_INTERLEAVED) {
|
|
|
|
int y;
|
|
|
|
for (y = 0; y <= vid.height; y += 2) {
|
|
|
|
glVertex2f(0, y - 0.5f);
|
|
|
|
glVertex2f(vid.width, y - 0.5f);
|
|
|
|
}
|
|
|
|
flip_eyes ^= (client_y & 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gl_state.stereo_mode == STEREO_MODE_COLUMN_INTERLEAVED || gl_state.stereo_mode == STEREO_MODE_PIXEL_INTERLEAVED) {
|
|
|
|
int x;
|
|
|
|
for (x = 0; x <= vid.width; x += 2) {
|
|
|
|
glVertex2f(x - 0.5f, 0);
|
|
|
|
glVertex2f(x - 0.5f, vid.height);
|
|
|
|
}
|
|
|
|
flip_eyes ^= (client_x & 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glStencilMask(GL_FALSE);
|
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
|
|
|
|
glStencilFunc(GL_EQUAL, drawing_left_eye ^ flip_eyes, 1);
|
|
|
|
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
|
|
|
}
|
|
|
|
break;
|
2016-04-07 14:57:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
2016-03-31 20:31:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_norefresh->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
r_newrefdef = *fd;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!r_worldmodel && !(r_newrefdef.rdflags & RDF_NOWORLDMODEL))
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Error(ERR_DROP, "R_RenderView: NULL worldmodel");
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_speeds->value)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
c_brush_polys = 0;
|
|
|
|
c_alias_polys = 0;
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_PushDlights();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_finish->value)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glFinish();
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_SetupFrame();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_SetFrustum();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_SetupGL();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_MarkLeaves(); /* done here so we know if we're in water */
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_DrawWorld();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_DrawEntitiesOnList();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_RenderDlights();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_DrawParticles();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
R_DrawAlphaSurfaces();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
R_Flash();
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_speeds->value)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\n",
|
2012-07-21 12:09:45 +00:00
|
|
|
c_brush_polys, c_alias_polys, c_visible_textures,
|
|
|
|
c_visible_lightmaps);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
2016-03-31 20:31:07 +00:00
|
|
|
|
|
|
|
switch (gl_state.stereo_mode) {
|
|
|
|
case STEREO_MODE_ANAGLYPH:
|
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
break;
|
|
|
|
case STEREO_MODE_ROW_INTERLEAVED:
|
|
|
|
case STEREO_MODE_COLUMN_INTERLEAVED:
|
|
|
|
case STEREO_MODE_PIXEL_INTERLEAVED:
|
|
|
|
glDisable(GL_STENCIL_TEST);
|
|
|
|
break;
|
2016-04-07 14:57:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
2016-03-31 20:31:07 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2016-03-31 20:31:07 +00:00
|
|
|
enum opengl_special_buffer_modes GL_GetSpecialBufferModeForStereoMode(enum stereo_modes stereo_mode) {
|
|
|
|
switch (stereo_mode) {
|
|
|
|
case STEREO_MODE_NONE:
|
2016-04-01 12:11:54 +00:00
|
|
|
case STEREO_SPLIT_HORIZONTAL:
|
|
|
|
case STEREO_SPLIT_VERTICAL:
|
2016-03-31 20:31:07 +00:00
|
|
|
case STEREO_MODE_ANAGLYPH:
|
|
|
|
return OPENGL_SPECIAL_BUFFER_MODE_NONE;
|
|
|
|
case STEREO_MODE_OPENGL:
|
|
|
|
return OPENGL_SPECIAL_BUFFER_MODE_STEREO;
|
|
|
|
case STEREO_MODE_ROW_INTERLEAVED:
|
|
|
|
case STEREO_MODE_COLUMN_INTERLEAVED:
|
|
|
|
case STEREO_MODE_PIXEL_INTERLEAVED:
|
|
|
|
return OPENGL_SPECIAL_BUFFER_MODE_STENCIL;
|
|
|
|
}
|
|
|
|
return OPENGL_SPECIAL_BUFFER_MODE_NONE;
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetLightLevel(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
vec3_t shadelight;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (r_newrefdef.rdflags & RDF_NOWORLDMODEL)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* save off light value for server to look at */
|
2012-07-21 12:09:45 +00:00
|
|
|
R_LightPoint(r_newrefdef.vieworg, shadelight);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
/* pick the greatest component, which should be the
|
|
|
|
* same as the mono value returned by software */
|
|
|
|
if (shadelight[0] > shadelight[1])
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (shadelight[0] > shadelight[2])
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
gl_lightlevel->value = 150 * shadelight[0];
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
gl_lightlevel->value = 150 * shadelight[2];
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (shadelight[1] > shadelight[2])
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
gl_lightlevel->value = 150 * shadelight[1];
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
gl_lightlevel->value = 150 * shadelight[2];
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_RenderFrame(refdef_t *fd)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_RenderView(fd);
|
2010-10-22 07:49:17 +00:00
|
|
|
R_SetLightLevel();
|
|
|
|
R_SetGL2D();
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Register(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
gl_lefthand = Cvar_Get("hand", "0", CVAR_USERINFO | CVAR_ARCHIVE);
|
|
|
|
gl_farsee = Cvar_Get("gl_farsee", "0", CVAR_LATCH | CVAR_ARCHIVE);
|
|
|
|
gl_norefresh = Cvar_Get("gl_norefresh", "0", 0);
|
|
|
|
gl_fullbright = Cvar_Get("gl_fullbright", "0", 0);
|
|
|
|
gl_drawentities = Cvar_Get("gl_drawentities", "1", 0);
|
|
|
|
gl_drawworld = Cvar_Get("gl_drawworld", "1", 0);
|
|
|
|
gl_novis = Cvar_Get("gl_novis", "0", 0);
|
|
|
|
gl_nocull = Cvar_Get("gl_nocull", "0", 0);
|
|
|
|
gl_lerpmodels = Cvar_Get("gl_lerpmodels", "1", 0);
|
|
|
|
gl_speeds = Cvar_Get("gl_speeds", "0", 0);
|
|
|
|
|
|
|
|
gl_lightlevel = Cvar_Get("gl_lightlevel", "0", 0);
|
|
|
|
gl_overbrightbits = Cvar_Get("gl_overbrightbits", "2", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
gl_nosubimage = Cvar_Get("gl_nosubimage", "0", 0);
|
|
|
|
gl_allow_software = Cvar_Get("gl_allow_software", "0", 0);
|
|
|
|
|
|
|
|
gl_particle_min_size = Cvar_Get("gl_particle_min_size", "2", CVAR_ARCHIVE);
|
|
|
|
gl_particle_max_size = Cvar_Get("gl_particle_max_size", "40", CVAR_ARCHIVE);
|
|
|
|
gl_particle_size = Cvar_Get("gl_particle_size", "40", CVAR_ARCHIVE);
|
|
|
|
gl_particle_att_a = Cvar_Get("gl_particle_att_a", "0.01", CVAR_ARCHIVE);
|
|
|
|
gl_particle_att_b = Cvar_Get("gl_particle_att_b", "0.0", CVAR_ARCHIVE);
|
|
|
|
gl_particle_att_c = Cvar_Get("gl_particle_att_c", "0.01", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
gl_modulate = Cvar_Get("gl_modulate", "1", CVAR_ARCHIVE);
|
|
|
|
gl_bitdepth = Cvar_Get("gl_bitdepth", "0", 0);
|
|
|
|
gl_mode = Cvar_Get("gl_mode", "4", CVAR_ARCHIVE);
|
|
|
|
gl_lightmap = Cvar_Get("gl_lightmap", "0", 0);
|
|
|
|
gl_shadows = Cvar_Get("gl_shadows", "0", CVAR_ARCHIVE);
|
|
|
|
gl_stencilshadow = Cvar_Get("gl_stencilshadow", "0", CVAR_ARCHIVE);
|
|
|
|
gl_dynamic = Cvar_Get("gl_dynamic", "1", 0);
|
|
|
|
gl_nobind = Cvar_Get("gl_nobind", "0", 0);
|
|
|
|
gl_round_down = Cvar_Get("gl_round_down", "1", 0);
|
|
|
|
gl_picmip = Cvar_Get("gl_picmip", "0", 0);
|
|
|
|
gl_skymip = Cvar_Get("gl_skymip", "0", 0);
|
|
|
|
gl_showtris = Cvar_Get("gl_showtris", "0", 0);
|
|
|
|
gl_ztrick = Cvar_Get("gl_ztrick", "0", 0);
|
|
|
|
gl_zfix = Cvar_Get("gl_zfix", "0", 0);
|
|
|
|
gl_finish = Cvar_Get("gl_finish", "0", CVAR_ARCHIVE);
|
|
|
|
gl_clear = Cvar_Get("gl_clear", "0", 0);
|
|
|
|
gl_cull = Cvar_Get("gl_cull", "1", 0);
|
|
|
|
gl_polyblend = Cvar_Get("gl_polyblend", "1", 0);
|
|
|
|
gl_flashblend = Cvar_Get("gl_flashblend", "0", 0);
|
|
|
|
gl_playermip = Cvar_Get("gl_playermip", "0", 0);
|
|
|
|
|
|
|
|
gl_texturemode = Cvar_Get("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE);
|
|
|
|
gl_texturealphamode = Cvar_Get("gl_texturealphamode", "default", CVAR_ARCHIVE);
|
|
|
|
gl_texturesolidmode = Cvar_Get("gl_texturesolidmode", "default", CVAR_ARCHIVE);
|
|
|
|
gl_anisotropic = Cvar_Get("gl_anisotropic", "0", CVAR_ARCHIVE);
|
|
|
|
gl_anisotropic_avail = Cvar_Get("gl_anisotropic_avail", "0", 0);
|
|
|
|
gl_lockpvs = Cvar_Get("gl_lockpvs", "0", 0);
|
|
|
|
gl_vertex_arrays = Cvar_Get("gl_vertex_arrays", "0", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
gl_ext_swapinterval = Cvar_Get("gl_ext_swapinterval", "1", CVAR_ARCHIVE);
|
|
|
|
gl_ext_palettedtexture = Cvar_Get("gl_ext_palettedtexture", "0", CVAR_ARCHIVE);
|
2016-05-01 07:01:27 +00:00
|
|
|
gl_ext_multitexture = Cvar_Get("gl_ext_multitexture", "0", CVAR_ARCHIVE);
|
2013-05-01 21:24:44 +00:00
|
|
|
gl_ext_pointparameters = Cvar_Get("gl_ext_pointparameters", "1", CVAR_ARCHIVE);
|
|
|
|
gl_ext_compiled_vertex_array = Cvar_Get("gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE);
|
|
|
|
gl_ext_mtexcombine = Cvar_Get("gl_ext_mtexcombine", "1", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
gl_drawbuffer = Cvar_Get("gl_drawbuffer", "GL_BACK", 0);
|
|
|
|
gl_swapinterval = Cvar_Get("gl_swapinterval", "1", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
gl_saturatelighting = Cvar_Get("gl_saturatelighting", "0", 0);
|
|
|
|
|
|
|
|
vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
|
|
|
|
vid_gamma = Cvar_Get("vid_gamma", "1.0", CVAR_ARCHIVE);
|
|
|
|
|
|
|
|
gl_customwidth = Cvar_Get("gl_customwidth", "1024", CVAR_ARCHIVE);
|
|
|
|
gl_customheight = Cvar_Get("gl_customheight", "768", CVAR_ARCHIVE);
|
2014-01-26 08:53:10 +00:00
|
|
|
gl_msaa_samples = Cvar_Get ( "gl_msaa_samples", "0", CVAR_ARCHIVE );
|
2010-05-22 06:58:09 +00:00
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
gl_retexturing = Cvar_Get("gl_retexturing", "1", CVAR_ARCHIVE);
|
2012-03-12 09:31:33 +00:00
|
|
|
|
2016-03-31 20:31:07 +00:00
|
|
|
|
2016-04-07 15:01:09 +00:00
|
|
|
gl_stereo = Cvar_Get( "gl_stereo", "0", CVAR_ARCHIVE );
|
|
|
|
gl_stereo_separation = Cvar_Get( "gl_stereo_separation", "-0.4", CVAR_ARCHIVE );
|
|
|
|
gl_stereo_anaglyph_colors = Cvar_Get( "gl_stereo_anaglyph_colors", "rc", CVAR_ARCHIVE );
|
|
|
|
gl_stereo_convergence = Cvar_Get( "gl_stereo_convergence", "1", CVAR_ARCHIVE );
|
2016-03-31 20:31:07 +00:00
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
Cmd_AddCommand("imagelist", R_ImageList_f);
|
|
|
|
Cmd_AddCommand("screenshot", R_ScreenShot);
|
|
|
|
Cmd_AddCommand("modellist", Mod_Modellist_f);
|
|
|
|
Cmd_AddCommand("gl_strings", R_Strings);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
qboolean
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetMode(void)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
rserr_t err;
|
|
|
|
qboolean fullscreen;
|
|
|
|
|
|
|
|
fullscreen = vid_fullscreen->value;
|
|
|
|
|
|
|
|
vid_fullscreen->modified = false;
|
|
|
|
gl_mode->modified = false;
|
2010-10-22 07:49:17 +00:00
|
|
|
|
|
|
|
/* a bit hackish approach to enable custom resolutions:
|
2012-07-21 12:09:45 +00:00
|
|
|
Glimp_SetMode needs these values set for mode -1 */
|
2010-01-08 14:19:29 +00:00
|
|
|
vid.width = gl_customwidth->value;
|
|
|
|
vid.height = gl_customheight->value;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if ((err = GLimp_SetMode(&vid.width, &vid.height, gl_mode->value,
|
|
|
|
fullscreen)) == rserr_ok)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_mode->value == -1)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-08-02 12:47:18 +00:00
|
|
|
gl_state.prev_mode = 4; /* safe default for custom mode */
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2010-01-08 14:19:29 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2010-01-08 14:19:29 +00:00
|
|
|
gl_state.prev_mode = gl_mode->value;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (err == rserr_invalid_fullscreen)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
Cvar_SetValue("vid_fullscreen", 0);
|
2009-03-05 09:07:55 +00:00
|
|
|
vid_fullscreen->modified = false;
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - fullscreen unavailable in this mode\n");
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if ((err = GLimp_SetMode(&vid.width, &vid.height, gl_mode->value, false)) == rserr_ok)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
return true;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
2012-07-21 12:09:45 +00:00
|
|
|
else if (err == rserr_invalid_mode)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
Cvar_SetValue("gl_mode", gl_state.prev_mode);
|
2009-03-05 09:07:55 +00:00
|
|
|
gl_mode->modified = false;
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - invalid mode\n");
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* try setting it back to something safe */
|
2014-03-28 20:12:15 +00:00
|
|
|
if ((err = GLimp_SetMode(&vid.width, &vid.height, gl_state.prev_mode, false)) != rserr_ok)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "ref_gl::R_SetMode() - could not revert to safe mode\n");
|
2012-07-21 12:09:45 +00:00
|
|
|
return false;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
return true;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
int
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Init(void *hinstance, void *hWnd)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
char renderer_buffer[1000];
|
|
|
|
char vendor_buffer[1000];
|
2010-10-22 07:49:17 +00:00
|
|
|
int err;
|
|
|
|
int j;
|
2012-07-21 12:09:45 +00:00
|
|
|
extern float r_turbsin[256];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
Swap_Init();
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (j = 0; j < 256; j++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
r_turbsin[j] *= 0.5;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-04-25 09:50:06 +00:00
|
|
|
/* Options */
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "Refresher build options:\n");
|
2015-03-19 15:56:30 +00:00
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, " + Retexturing support\n");
|
2015-03-19 15:56:30 +00:00
|
|
|
|
2012-04-28 20:04:24 +00:00
|
|
|
#ifdef X11GAMMA
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, " + Gamma via X11\n");
|
2012-04-25 09:50:06 +00:00
|
|
|
#else
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, " - Gamma via X11\n");
|
2012-04-25 09:50:06 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "Refresh: " REF_VERSION "\n");
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
Draw_GetPalette();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
|
|
|
R_Register();
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* initialize our QGL dynamic bindings */
|
2013-06-15 07:01:12 +00:00
|
|
|
QGL_Init();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* initialize OS-specific parts of OpenGL */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!GLimp_Init())
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
QGL_Shutdown();
|
2012-07-21 12:09:45 +00:00
|
|
|
return -1;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2014-03-28 20:12:15 +00:00
|
|
|
/* set our "safe" mode */
|
|
|
|
gl_state.prev_mode = 4;
|
2016-04-07 15:01:09 +00:00
|
|
|
gl_state.stereo_mode = gl_stereo->value;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* create the window and set up the context */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!R_SetMode())
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
QGL_Shutdown();
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "ref_gl::R_Init() - could not R_SetMode()\n");
|
2012-07-21 12:09:45 +00:00
|
|
|
return -1;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_MenuInit();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* get our various GL strings */
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "\nOpenGL setting:\n", gl_config.vendor_string);
|
2013-07-27 06:44:07 +00:00
|
|
|
gl_config.vendor_string = (char *)glGetString(GL_VENDOR);
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "GL_VENDOR: %s\n", gl_config.vendor_string);
|
2013-07-27 06:44:07 +00:00
|
|
|
gl_config.renderer_string = (char *)glGetString(GL_RENDERER);
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "GL_RENDERER: %s\n", gl_config.renderer_string);
|
2013-07-27 06:44:07 +00:00
|
|
|
gl_config.version_string = (char *)glGetString(GL_VERSION);
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "GL_VERSION: %s\n", gl_config.version_string);
|
2013-07-27 06:44:07 +00:00
|
|
|
gl_config.extensions_string = (char *)glGetString(GL_EXTENSIONS);
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "GL_EXTENSIONS: %s\n", gl_config.extensions_string);
|
2012-07-21 12:09:45 +00:00
|
|
|
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(renderer_buffer, gl_config.renderer_string, sizeof(renderer_buffer));
|
2013-05-11 10:46:49 +00:00
|
|
|
Q_strlwr(renderer_buffer);
|
2012-07-21 12:09:45 +00:00
|
|
|
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(vendor_buffer, gl_config.vendor_string, sizeof(vendor_buffer));
|
2013-05-11 10:46:49 +00:00
|
|
|
Q_strlwr(vendor_buffer);
|
2012-07-21 12:09:45 +00:00
|
|
|
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "\n\nProbing for OpenGL extensions:\n");
|
2010-10-25 12:55:59 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* grab extensions */
|
2013-07-27 06:44:44 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_EXT_compiled_vertex_array"))
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_EXT_compiled_vertex_array\n");
|
2013-07-27 06:50:20 +00:00
|
|
|
qglLockArraysEXT = ( void * ) GLimp_GetProcAddress ( "glLockArraysEXT" );
|
|
|
|
qglUnlockArraysEXT = ( void * ) GLimp_GetProcAddress ( "glUnlockArraysEXT" );
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_EXT_compiled_vertex_array not found\n");
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_EXT_point_parameters"))
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_ext_pointparameters->value)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_EXT_point_parameters\n");
|
2012-07-21 12:09:45 +00:00
|
|
|
qglPointParameterfEXT = (void (APIENTRY *)(GLenum, GLfloat))
|
2013-07-27 06:50:20 +00:00
|
|
|
GLimp_GetProcAddress ( "glPointParameterfEXT" );
|
2012-07-21 12:09:45 +00:00
|
|
|
qglPointParameterfvEXT = (void (APIENTRY *)(GLenum, const GLfloat *))
|
2013-07-27 06:50:20 +00:00
|
|
|
GLimp_GetProcAddress ( "glPointParameterfvEXT" );
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...ignoring GL_EXT_point_parameters\n");
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_EXT_point_parameters not found\n");
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!qglColorTableEXT &&
|
|
|
|
strstr(gl_config.extensions_string, "GL_EXT_paletted_texture") &&
|
|
|
|
strstr(gl_config.extensions_string, "GL_EXT_shared_texture_palette"))
|
2010-10-25 12:55:59 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_ext_palettedtexture->value)
|
2010-10-25 12:55:59 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_EXT_shared_texture_palette\n");
|
2010-10-25 12:55:59 +00:00
|
|
|
qglColorTableEXT =
|
2012-07-21 12:09:45 +00:00
|
|
|
(void (APIENTRY *)(GLenum, GLenum, GLsizei, GLenum, GLenum,
|
2013-07-27 06:50:20 +00:00
|
|
|
const GLvoid * ) ) GLimp_GetProcAddress ("glColorTableEXT");
|
2010-10-25 12:55:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...ignoring GL_EXT_shared_texture_palette\n");
|
2010-10-25 12:55:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_EXT_shared_texture_palette not found\n");
|
2010-10-25 12:55:59 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_ARB_multitexture"))
|
2010-10-25 12:33:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_ext_multitexture->value)
|
2010-10-25 12:33:55 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_ARB_multitexture\n");
|
2013-07-27 06:50:20 +00:00
|
|
|
qglMultiTexCoord2fARB = ( void * ) GLimp_GetProcAddress ( "glMultiTexCoord2fARB" );
|
2016-08-05 16:27:05 +00:00
|
|
|
qglMultiTexCoord2fvARB = (void * ) GLimp_GetProcAddress( "glMultiTexCoord2fvARB" );
|
2013-07-27 06:50:20 +00:00
|
|
|
qglActiveTextureARB = ( void * ) GLimp_GetProcAddress ( "glActiveTextureARB" );
|
|
|
|
qglClientActiveTextureARB = ( void * ) GLimp_GetProcAddress ( "glClientActiveTextureARB" );
|
2010-10-25 12:33:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...ignoring GL_ARB_multitexture\n");
|
2010-10-25 12:33:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_ARB_multitexture not found\n");
|
2010-10-25 12:33:55 +00:00
|
|
|
}
|
|
|
|
|
2011-10-17 10:43:48 +00:00
|
|
|
gl_config.anisotropic = false;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_EXT_texture_filter_anisotropic"))
|
2011-10-17 10:43:48 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_EXT_texture_filter_anisotropic\n");
|
2011-10-17 10:43:48 +00:00
|
|
|
gl_config.anisotropic = true;
|
2013-07-27 06:44:07 +00:00
|
|
|
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_config.max_anisotropy);
|
2013-05-01 21:24:44 +00:00
|
|
|
Cvar_SetValue("gl_anisotropic_avail", gl_config.max_anisotropy);
|
2011-10-17 10:43:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_EXT_texture_filter_anisotropic not found\n");
|
2011-10-17 10:43:48 +00:00
|
|
|
gl_config.anisotropic = false;
|
|
|
|
gl_config.max_anisotropy = 0.0;
|
2013-05-01 21:24:44 +00:00
|
|
|
Cvar_SetValue("gl_anisotropic_avail", 0.0);
|
2012-04-29 13:57:33 +00:00
|
|
|
}
|
2011-10-17 10:43:48 +00:00
|
|
|
|
2015-02-27 12:29:54 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_ARB_texture_non_power_of_two"))
|
|
|
|
{
|
|
|
|
VID_Printf(PRINT_ALL, "...using GL_ARB_texture_non_power_of_two\n");
|
|
|
|
gl_config.tex_npot = true;
|
|
|
|
}
|
|
|
|
|
2010-10-25 13:21:52 +00:00
|
|
|
gl_config.mtexcombine = false;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_ARB_texture_env_combine"))
|
2010-10-25 13:21:52 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_ext_mtexcombine->value)
|
2010-10-25 13:21:52 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_ARB_texture_env_combine\n");
|
2010-10-25 13:21:52 +00:00
|
|
|
gl_config.mtexcombine = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...ignoring GL_ARB_texture_env_combine\n");
|
2010-10-25 13:21:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_ARB_texture_env_combine not found\n");
|
2010-10-25 13:21:52 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (!gl_config.mtexcombine)
|
2010-10-25 13:21:52 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (strstr(gl_config.extensions_string, "GL_EXT_texture_env_combine"))
|
2010-10-25 13:21:52 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_ext_mtexcombine->value)
|
2010-10-25 13:21:52 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...using GL_EXT_texture_env_combine\n");
|
2010-10-25 13:21:52 +00:00
|
|
|
gl_config.mtexcombine = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...ignoring GL_EXT_texture_env_combine\n");
|
2010-10-25 13:21:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "...GL_EXT_texture_env_combine not found\n");
|
2010-10-25 13:21:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-23 07:19:40 +00:00
|
|
|
R_SetDefaultState();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 09:12:38 +00:00
|
|
|
R_InitImages();
|
2010-10-22 07:49:17 +00:00
|
|
|
Mod_Init();
|
|
|
|
R_InitParticleTexture();
|
|
|
|
Draw_InitLocal();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
err = glGetError();
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (err != GL_NO_ERROR)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
VID_Printf(PRINT_ALL, "glGetError() = 0x%x\n", err);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
return true;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_Shutdown(void)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-05-01 21:24:44 +00:00
|
|
|
Cmd_RemoveCommand("modellist");
|
|
|
|
Cmd_RemoveCommand("screenshot");
|
|
|
|
Cmd_RemoveCommand("imagelist");
|
|
|
|
Cmd_RemoveCommand("gl_strings");
|
2010-10-22 07:49:17 +00:00
|
|
|
|
|
|
|
Mod_FreeAll();
|
|
|
|
|
2010-10-22 09:12:38 +00:00
|
|
|
R_ShutdownImages();
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
/* shutdown OS specific OpenGL stuff like contexts, etc. */
|
2009-03-05 09:07:55 +00:00
|
|
|
GLimp_Shutdown();
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* shutdown our QGL subsystem */
|
2009-03-05 09:07:55 +00:00
|
|
|
QGL_Shutdown();
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
extern void UpdateHardwareGamma();
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_BeginFrame(float camera_separation)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
gl_state.camera_separation = camera_separation;
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* change modes if necessary */
|
2013-04-29 21:07:55 +00:00
|
|
|
if (gl_mode->modified)
|
2010-10-25 12:33:55 +00:00
|
|
|
{
|
2013-04-29 21:07:55 +00:00
|
|
|
vid_fullscreen->modified = true;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2016-04-07 15:01:09 +00:00
|
|
|
// force a vid_restart if gl_stereo has been modified.
|
|
|
|
if ( gl_state.stereo_mode != gl_stereo->value ) {
|
2016-03-31 20:31:07 +00:00
|
|
|
// If we've gone from one mode to another with the same special buffer requirements there's no need to restart.
|
2016-04-07 15:01:09 +00:00
|
|
|
if ( GL_GetSpecialBufferModeForStereoMode( gl_state.stereo_mode ) == GL_GetSpecialBufferModeForStereoMode( gl_stereo->value ) ) {
|
|
|
|
gl_state.stereo_mode = gl_stereo->value;
|
2016-03-31 20:31:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VID_Printf(PRINT_ALL, "stereo supermode changed, restarting video!\n");
|
|
|
|
cvar_t *ref;
|
|
|
|
ref = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
|
|
|
|
ref->modified = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (vid_gamma->modified)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
vid_gamma->modified = false;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_state.hwgamma)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
UpdateHardwareGamma();
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* go into 2D mode */
|
2016-04-04 16:33:18 +00:00
|
|
|
|
|
|
|
int x, w, y, h;
|
|
|
|
qboolean drawing_left_eye = gl_state.camera_separation < 0;
|
|
|
|
qboolean stereo_split_tb = ((gl_state.stereo_mode == STEREO_SPLIT_VERTICAL) && gl_state.camera_separation);
|
|
|
|
qboolean stereo_split_lr = ((gl_state.stereo_mode == STEREO_SPLIT_HORIZONTAL) && gl_state.camera_separation);
|
|
|
|
|
|
|
|
x = 0;
|
|
|
|
w = vid.width;
|
|
|
|
y = 0;
|
|
|
|
h = vid.height;
|
|
|
|
|
|
|
|
if(stereo_split_lr) {
|
|
|
|
w = w / 2;
|
|
|
|
x = drawing_left_eye ? 0 : w;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(stereo_split_tb) {
|
|
|
|
h = h / 2;
|
|
|
|
y = drawing_left_eye ? h : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
glViewport(x, y, w, h);
|
2013-07-27 06:44:07 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glLoadIdentity();
|
|
|
|
glOrtho(0, vid.width, vid.height, 0, -99999, 99999);
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glLoadIdentity();
|
|
|
|
glDisable(GL_DEPTH_TEST);
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glEnable(GL_ALPHA_TEST);
|
|
|
|
glColor4f(1, 1, 1, 1);
|
2010-10-22 07:49:17 +00:00
|
|
|
|
|
|
|
/* draw buffer stuff */
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_drawbuffer->modified)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
|
|
|
gl_drawbuffer->modified = false;
|
|
|
|
|
2016-03-31 20:31:07 +00:00
|
|
|
if ((gl_state.camera_separation == 0) || gl_state.stereo_mode != STEREO_MODE_OPENGL)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
if (Q_stricmp(gl_drawbuffer->string, "GL_FRONT") == 0)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glDrawBuffer(GL_FRONT);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
else
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2013-07-27 06:44:07 +00:00
|
|
|
glDrawBuffer(GL_BACK);
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* texturemode stuff */
|
2014-05-01 19:20:00 +00:00
|
|
|
if (gl_texturemode->modified || (gl_config.anisotropic && gl_anisotropic->modified))
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TextureMode(gl_texturemode->string);
|
2009-03-05 09:07:55 +00:00
|
|
|
gl_texturemode->modified = false;
|
2014-05-01 19:20:00 +00:00
|
|
|
gl_anisotropic->modified = false;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_texturealphamode->modified)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TextureAlphaMode(gl_texturealphamode->string);
|
2009-03-05 09:07:55 +00:00
|
|
|
gl_texturealphamode->modified = false;
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (gl_texturesolidmode->modified)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
R_TextureSolidMode(gl_texturesolidmode->string);
|
2009-03-05 09:07:55 +00:00
|
|
|
gl_texturesolidmode->modified = false;
|
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* clear screen if desired */
|
|
|
|
R_Clear();
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetPalette(const unsigned char *palette)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
int i;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
byte *rp = (byte *)r_rawpalette;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (palette)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 256; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
rp[i * 4 + 0] = palette[i * 3 + 0];
|
|
|
|
rp[i * 4 + 1] = palette[i * 3 + 1];
|
|
|
|
rp[i * 4 + 2] = palette[i * 3 + 2];
|
|
|
|
rp[i * 4 + 3] = 0xff;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 256; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
rp[i * 4 + 0] = LittleLong(d_8to24table[i]) & 0xff;
|
|
|
|
rp[i * 4 + 1] = (LittleLong(d_8to24table[i]) >> 8) & 0xff;
|
|
|
|
rp[i * 4 + 2] = (LittleLong(d_8to24table[i]) >> 16) & 0xff;
|
|
|
|
rp[i * 4 + 3] = 0xff;
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
R_SetTexturePalette(r_rawpalette);
|
2010-10-25 12:55:59 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glClearColor(0, 0, 0, 0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
glClearColor(1, 0, 0.5, 0.5);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
/* R_DrawBeam */
|
|
|
|
void
|
2012-07-21 12:09:45 +00:00
|
|
|
R_DrawBeam(entity_t *e)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2010-10-22 07:49:17 +00:00
|
|
|
int i;
|
2009-03-05 09:07:55 +00:00
|
|
|
float r, g, b;
|
|
|
|
|
|
|
|
vec3_t perpvec;
|
|
|
|
vec3_t direction, normalized_direction;
|
2012-07-21 12:09:45 +00:00
|
|
|
vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
|
2009-03-05 09:07:55 +00:00
|
|
|
vec3_t oldorigin, origin;
|
2014-06-14 08:07:33 +00:00
|
|
|
|
|
|
|
GLfloat vtx[3*NUM_BEAM_SEGS*4];
|
|
|
|
unsigned int index_vtx = 0;
|
|
|
|
unsigned int pointb;
|
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
oldorigin[0] = e->oldorigin[0];
|
|
|
|
oldorigin[1] = e->oldorigin[1];
|
|
|
|
oldorigin[2] = e->oldorigin[2];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
origin[0] = e->origin[0];
|
|
|
|
origin[1] = e->origin[1];
|
|
|
|
origin[2] = e->origin[2];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
|
|
|
|
normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
|
|
|
|
normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
if (VectorNormalize(normalized_direction) == 0)
|
2010-10-22 07:49:17 +00:00
|
|
|
{
|
2009-03-05 09:07:55 +00:00
|
|
|
return;
|
2010-10-22 07:49:17 +00:00
|
|
|
}
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
PerpendicularVector(perpvec, normalized_direction);
|
|
|
|
VectorScale(perpvec, e->frame / 2, perpvec);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2012-07-21 12:09:45 +00:00
|
|
|
RotatePointAroundVector(start_points[i], normalized_direction, perpvec,
|
|
|
|
(360.0 / NUM_BEAM_SEGS) * i);
|
|
|
|
VectorAdd(start_points[i], origin, start_points[i]);
|
|
|
|
VectorAdd(start_points[i], direction, end_points[i]);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glDepthMask(GL_FALSE);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2012-07-21 12:09:45 +00:00
|
|
|
r = (LittleLong(d_8to24table[e->skinnum & 0xFF])) & 0xFF;
|
|
|
|
g = (LittleLong(d_8to24table[e->skinnum & 0xFF]) >> 8) & 0xFF;
|
|
|
|
b = (LittleLong(d_8to24table[e->skinnum & 0xFF]) >> 16) & 0xFF;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2010-10-22 07:49:17 +00:00
|
|
|
r *= 1 / 255.0F;
|
|
|
|
g *= 1 / 255.0F;
|
|
|
|
b *= 1 / 255.0F;
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glColor4f(r, g, b, e->alpha);
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
for ( i = 0; i < NUM_BEAM_SEGS; i++ )
|
2009-03-05 09:07:55 +00:00
|
|
|
{
|
2014-06-14 08:07:33 +00:00
|
|
|
vtx[index_vtx++] = start_points [ i ][ 0 ];
|
|
|
|
vtx[index_vtx++] = start_points [ i ][ 1 ];
|
|
|
|
vtx[index_vtx++] = start_points [ i ][ 2 ];
|
|
|
|
|
|
|
|
vtx[index_vtx++] = end_points [ i ][ 0 ];
|
|
|
|
vtx[index_vtx++] = end_points [ i ][ 1 ];
|
|
|
|
vtx[index_vtx++] = end_points [ i ][ 2 ];
|
|
|
|
|
|
|
|
pointb = ( i + 1 ) % NUM_BEAM_SEGS;
|
|
|
|
vtx[index_vtx++] = start_points [ pointb ][ 0 ];
|
|
|
|
vtx[index_vtx++] = start_points [ pointb ][ 1 ];
|
|
|
|
vtx[index_vtx++] = start_points [ pointb ][ 2 ];
|
|
|
|
|
|
|
|
vtx[index_vtx++] = end_points [ pointb ][ 0 ];
|
|
|
|
vtx[index_vtx++] = end_points [ pointb ][ 1 ];
|
|
|
|
vtx[index_vtx++] = end_points [ pointb ][ 2 ];
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
2010-10-22 07:49:17 +00:00
|
|
|
|
2014-06-14 08:07:33 +00:00
|
|
|
glEnableClientState( GL_VERTEX_ARRAY );
|
|
|
|
|
|
|
|
glVertexPointer( 3, GL_FLOAT, 0, vtx );
|
|
|
|
glDrawArrays( GL_TRIANGLE_STRIP, 0, NUM_BEAM_SEGS*4 );
|
|
|
|
|
|
|
|
glDisableClientState( GL_VERTEX_ARRAY );
|
2009-03-05 09:07:55 +00:00
|
|
|
|
2013-07-27 06:44:07 +00:00
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glDepthMask(GL_TRUE);
|
2009-03-05 09:07:55 +00:00
|
|
|
}
|
|
|
|
|