2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-07-20 02:50:00 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2004-08-22 22:29:09 +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 the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// r_main.c
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
2004-12-15 19:53:30 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef GLQUAKE
|
2004-08-22 22:29:09 +00:00
|
|
|
#include "glquake.h"
|
2006-02-11 14:51:36 +00:00
|
|
|
#include "renderque.h"
|
2005-08-26 22:56:51 +00:00
|
|
|
#include "shader.h"
|
2010-03-25 22:56:11 +00:00
|
|
|
#include "gl_draw.h"
|
2005-08-26 22:56:51 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
void R_RenderBrushPoly (msurface_t *fa);
|
|
|
|
|
|
|
|
#define PROJECTION_DISTANCE 200
|
|
|
|
#define MAX_STENCIL_ENTS 128
|
|
|
|
|
|
|
|
extern int gl_canstencil;
|
|
|
|
|
2007-09-22 19:28:27 +00:00
|
|
|
FTEPFNGLCOMPRESSEDTEXIMAGE2DARBPROC qglCompressedTexImage2DARB;
|
|
|
|
FTEPFNGLGETCOMPRESSEDTEXIMAGEARBPROC qglGetCompressedTexImageARB;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
#define Q2RF_WEAPONMODEL 4 // only draw through eyes
|
|
|
|
#define Q2RF_DEPTHHACK 16
|
|
|
|
|
|
|
|
entity_t r_worldentity;
|
|
|
|
|
|
|
|
vec3_t modelorg, r_entorigin;
|
|
|
|
|
|
|
|
int r_visframecount; // bumped when going to a new PVS
|
2009-11-04 23:20:50 +00:00
|
|
|
extern int r_framecount; // used for dlight push checking
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
float r_wateralphaval; //allowed or not...
|
|
|
|
|
2007-05-25 22:16:29 +00:00
|
|
|
//mplane_t frustum[4];
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
int c_brush_polys, c_alias_polys;
|
|
|
|
|
|
|
|
//
|
|
|
|
// view origin
|
|
|
|
//
|
|
|
|
vec3_t vup;
|
|
|
|
vec3_t vpn;
|
|
|
|
vec3_t vright;
|
|
|
|
vec3_t r_origin;
|
|
|
|
|
|
|
|
//
|
|
|
|
// screen size info
|
|
|
|
//
|
|
|
|
refdef_t r_refdef;
|
|
|
|
|
|
|
|
mleaf_t *r_viewleaf, *r_oldviewleaf;
|
|
|
|
mleaf_t *r_viewleaf2, *r_oldviewleaf2;
|
|
|
|
int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
|
|
|
|
|
|
|
|
texture_t *r_notexture_mip;
|
|
|
|
|
2006-02-11 02:09:43 +00:00
|
|
|
cvar_t r_norefresh = SCVAR("r_norefresh","0");
|
|
|
|
cvar_t r_mirroralpha = SCVARF("r_mirroralpha","1", CVAR_CHEAT);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
extern cvar_t gl_part_flame;
|
2010-07-11 02:22:39 +00:00
|
|
|
extern cvar_t r_bloom;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2006-02-11 02:09:43 +00:00
|
|
|
cvar_t gl_clear = SCVAR("gl_clear","0");
|
|
|
|
cvar_t gl_smoothmodels = SCVAR("gl_smoothmodels","1");
|
|
|
|
cvar_t gl_affinemodels = SCVAR("gl_affinemodels","0");
|
|
|
|
cvar_t gl_playermip = SCVAR("gl_playermip","0");
|
|
|
|
cvar_t gl_keeptjunctions = SCVAR("gl_keeptjunctions","1");
|
|
|
|
cvar_t gl_reporttjunctions = SCVAR("gl_reporttjunctions","0");
|
|
|
|
cvar_t gl_finish = SCVAR("gl_finish","0");
|
|
|
|
cvar_t gl_dither = SCVAR("gl_dither", "1");
|
|
|
|
cvar_t gl_maxdist = SCVAR("gl_maxdist", "8192");
|
2007-08-21 17:16:52 +00:00
|
|
|
|
2009-07-19 20:43:07 +00:00
|
|
|
cvar_t r_polygonoffset_submodel_factor = SCVAR("r_polygonoffset_submodel_factor", "0.05");
|
|
|
|
cvar_t r_polygonoffset_submodel_offset = SCVAR("r_polygonoffset_submodel_offset", "25");
|
|
|
|
|
2007-05-25 22:16:29 +00:00
|
|
|
extern cvar_t gl_mindist;
|
2006-02-11 02:09:43 +00:00
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
extern cvar_t ffov;
|
|
|
|
|
2005-05-27 08:24:31 +00:00
|
|
|
extern cvar_t gl_motionblur;
|
2005-06-04 04:20:20 +00:00
|
|
|
extern cvar_t gl_motionblurscale;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
extern cvar_t gl_ati_truform;
|
|
|
|
extern cvar_t gl_ati_truform_type;
|
|
|
|
extern cvar_t gl_ati_truform_tesselation;
|
|
|
|
|
2005-08-23 23:36:04 +00:00
|
|
|
extern cvar_t gl_blendsprites;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
#ifdef R_XFLIP
|
2006-02-11 02:09:43 +00:00
|
|
|
cvar_t r_xflip = SCVAR("leftisright", "0");
|
2004-08-22 22:29:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern cvar_t gl_ztrick;
|
|
|
|
extern cvar_t scr_fov;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
shader_t *scenepp_waterwarp;
|
|
|
|
|
2005-01-12 22:15:50 +00:00
|
|
|
// post processing stuff
|
2009-11-04 21:16:50 +00:00
|
|
|
texid_t sceneblur_texture;
|
|
|
|
texid_t scenepp_texture;
|
|
|
|
texid_t scenepp_texture_warp;
|
|
|
|
texid_t scenepp_texture_edge;
|
2005-01-12 22:15:50 +00:00
|
|
|
|
|
|
|
int scenepp_ww_program;
|
2005-01-17 18:06:45 +00:00
|
|
|
int scenepp_ww_parm_texture0i;
|
|
|
|
int scenepp_ww_parm_texture1i;
|
|
|
|
int scenepp_ww_parm_texture2i;
|
2005-01-12 22:15:50 +00:00
|
|
|
int scenepp_ww_parm_ampscalef;
|
|
|
|
|
2006-03-14 09:20:07 +00:00
|
|
|
int scenepp_mt_program;
|
|
|
|
int scenepp_mt_parm_texture0i;
|
|
|
|
int scenepp_mt_parm_colorf;
|
|
|
|
int scenepp_mt_parm_inverti;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
texid_t scenepp_fisheye_texture;
|
2009-07-19 18:13:03 +00:00
|
|
|
int scenepp_fisheye_program;
|
|
|
|
int scenepp_fisheye_parm_fov;
|
|
|
|
int scenepp_panorama_program;
|
|
|
|
int scenepp_panorama_parm_fov;
|
|
|
|
|
2005-01-12 22:15:50 +00:00
|
|
|
// KrimZon - init post processing - called in GL_CheckExtensions, when they're called
|
|
|
|
// I put it here so that only this file need be changed when messing with the post
|
|
|
|
// processing shaders
|
2005-08-26 22:56:51 +00:00
|
|
|
void GL_InitSceneProcessingShaders_WaterWarp (void)
|
2005-01-12 22:15:50 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
#if 1
|
|
|
|
/*
|
|
|
|
inputs:
|
|
|
|
texcoords: edge points
|
|
|
|
coords: vertex coords (duh)
|
|
|
|
time
|
|
|
|
ampscale (cvar = r_waterwarp)
|
|
|
|
|
|
|
|
use ifs instead of an edge map?
|
|
|
|
*/
|
|
|
|
if (gl_config.arb_shader_objects)
|
|
|
|
{
|
|
|
|
scenepp_waterwarp = R_RegisterShader("waterwarp",
|
|
|
|
"{\n"
|
|
|
|
"glslprogram\n"
|
|
|
|
"{\n"
|
|
|
|
"#ifdef VERTEX_SHADER\n"
|
|
|
|
"\
|
|
|
|
varying vec2 v_stc;\
|
|
|
|
varying vec2 v_warp;\
|
|
|
|
varying vec2 v_edge;\
|
|
|
|
uniform float time;\
|
|
|
|
void main (void)\
|
|
|
|
{\
|
|
|
|
gl_Position = ftransform();\
|
|
|
|
v_stc = (1.0+(gl_Position.xy / gl_Position.w))/2.0;\
|
|
|
|
v_warp.s = "/*FIXME: Multiply by screen matricies*/"time * 0.25 + gl_MultiTexCoord0.s;\
|
|
|
|
v_warp.t = time * 0.25 + gl_MultiTexCoord0.t;\
|
|
|
|
v_edge = gl_MultiTexCoord0.xy;\
|
|
|
|
}\
|
|
|
|
\n"
|
|
|
|
"#endif\n"
|
|
|
|
"#ifdef FRAGMENT_SHADER\n"
|
|
|
|
"\
|
|
|
|
varying vec2 v_stc;\
|
|
|
|
varying vec2 v_warp;\
|
|
|
|
varying vec2 v_edge;\
|
|
|
|
uniform sampler2D texScreen;\
|
|
|
|
uniform sampler2D texWarp;\
|
|
|
|
uniform sampler2D texEdge;\
|
|
|
|
uniform float ampscale;\
|
|
|
|
void main (void)\
|
|
|
|
{\
|
|
|
|
float amptemp;\
|
|
|
|
vec3 edge;\
|
|
|
|
edge = texture2D( texEdge, v_edge ).rgb;\
|
|
|
|
amptemp = (0.010 / 0.625) * ampscale * edge.x;\
|
|
|
|
vec3 offset;\
|
|
|
|
offset = texture2D( texWarp, v_warp ).rgb;\
|
|
|
|
offset.x = (offset.x - 0.5) * 2.0;\
|
|
|
|
offset.y = (offset.y - 0.5) * 2.0;\
|
|
|
|
vec2 temp;\
|
|
|
|
temp.x = v_stc.x + offset.x * amptemp;\
|
|
|
|
temp.y = v_stc.y + offset.y * amptemp;\
|
|
|
|
gl_FragColor = texture2D( texScreen, temp );\
|
|
|
|
}\
|
|
|
|
\n"
|
|
|
|
"#endif\n"
|
|
|
|
"}\n"
|
|
|
|
"param cvarf r_waterwarp ampscale\n"
|
|
|
|
"param texture 0 texScreen\n"
|
|
|
|
"param texture 1 texWarp\n"
|
|
|
|
"param texture 2 texEdge\n"
|
|
|
|
"param time time\n"
|
|
|
|
"{\n"
|
|
|
|
"map $currentrender\n"
|
|
|
|
"}\n"
|
|
|
|
"{\n"
|
|
|
|
"map $upperoverlay\n"
|
|
|
|
"}\n"
|
|
|
|
"{\n"
|
|
|
|
"map $loweroverlay\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
|
|
|
scenepp_waterwarp->defaulttextures.upperoverlay = scenepp_texture_warp;
|
|
|
|
scenepp_waterwarp->defaulttextures.loweroverlay = scenepp_texture_edge;
|
|
|
|
}
|
|
|
|
#else
|
2005-01-12 22:15:50 +00:00
|
|
|
char *genericvert = "\
|
2005-01-17 18:06:45 +00:00
|
|
|
varying vec2 v_texCoord0;\
|
|
|
|
varying vec2 v_texCoord1;\
|
|
|
|
varying vec2 v_texCoord2;\
|
2005-01-12 22:15:50 +00:00
|
|
|
void main (void)\
|
|
|
|
{\
|
|
|
|
vec4 v = vec4( gl_Vertex.x, gl_Vertex.y, gl_Vertex.z, 1.0 );\
|
|
|
|
gl_Position = gl_ModelViewProjectionMatrix * v;\
|
2005-01-17 18:06:45 +00:00
|
|
|
v_texCoord0 = gl_MultiTexCoord0.xy;\
|
|
|
|
v_texCoord1 = gl_MultiTexCoord1.xy;\
|
|
|
|
v_texCoord2 = gl_MultiTexCoord2.xy;\
|
2005-01-12 22:15:50 +00:00
|
|
|
}\
|
|
|
|
";
|
|
|
|
|
|
|
|
char *wwfrag = "\
|
2005-01-17 18:06:45 +00:00
|
|
|
varying vec2 v_texCoord0;\
|
|
|
|
varying vec2 v_texCoord1;\
|
|
|
|
varying vec2 v_texCoord2;\
|
|
|
|
uniform sampler2D theTexture0;\
|
|
|
|
uniform sampler2D theTexture1;\
|
|
|
|
uniform sampler2D theTexture2;\
|
2005-01-12 22:15:50 +00:00
|
|
|
uniform float ampscale;\
|
|
|
|
void main (void)\
|
|
|
|
{\
|
2005-01-17 18:06:45 +00:00
|
|
|
float amptemp;\
|
|
|
|
vec3 edge;\
|
2005-01-18 21:05:43 +00:00
|
|
|
edge = texture2D( theTexture2, v_texCoord2 ).rgb;\
|
2005-01-17 18:06:45 +00:00
|
|
|
amptemp = ampscale * edge.x;\
|
|
|
|
vec3 offset;\
|
2005-01-18 21:05:43 +00:00
|
|
|
offset = texture2D( theTexture1, v_texCoord1 ).rgb;\
|
2005-01-17 18:06:45 +00:00
|
|
|
offset.x = (offset.x - 0.5) * 2.0;\
|
|
|
|
offset.y = (offset.y - 0.5) * 2.0;\
|
2005-01-13 15:18:02 +00:00
|
|
|
vec2 temp;\
|
2005-01-17 18:06:45 +00:00
|
|
|
temp.x = v_texCoord0.x + offset.x * amptemp;\
|
|
|
|
temp.y = v_texCoord0.y + offset.y * amptemp;\
|
|
|
|
gl_FragColor = texture2D( theTexture0, temp );\
|
2005-01-12 22:15:50 +00:00
|
|
|
}\
|
|
|
|
";
|
|
|
|
|
2005-01-13 15:18:02 +00:00
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("GL Error before initing shader object\n");
|
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
scenepp_ww_program = GLSlang_CreateProgram(NULL, genericvert, wwfrag);
|
2005-01-13 15:18:02 +00:00
|
|
|
|
2005-01-18 21:05:43 +00:00
|
|
|
if (!scenepp_ww_program)
|
|
|
|
return;
|
|
|
|
|
2005-01-17 18:06:45 +00:00
|
|
|
scenepp_ww_parm_texture0i = GLSlang_GetUniformLocation(scenepp_ww_program, "theTexture0");
|
|
|
|
scenepp_ww_parm_texture1i = GLSlang_GetUniformLocation(scenepp_ww_program, "theTexture1");
|
|
|
|
scenepp_ww_parm_texture2i = GLSlang_GetUniformLocation(scenepp_ww_program, "theTexture2");
|
2005-01-12 22:15:50 +00:00
|
|
|
scenepp_ww_parm_ampscalef = GLSlang_GetUniformLocation(scenepp_ww_program, "ampscale");
|
2005-01-13 15:18:02 +00:00
|
|
|
|
|
|
|
GLSlang_UseProgram(scenepp_ww_program);
|
|
|
|
|
2005-01-17 18:06:45 +00:00
|
|
|
GLSlang_SetUniform1i(scenepp_ww_parm_texture0i, 0);
|
|
|
|
GLSlang_SetUniform1i(scenepp_ww_parm_texture1i, 1);
|
|
|
|
GLSlang_SetUniform1i(scenepp_ww_parm_texture2i, 2);
|
2005-01-13 15:18:02 +00:00
|
|
|
|
2005-01-16 02:31:39 +00:00
|
|
|
GLSlang_UseProgram(0);
|
2005-01-12 22:15:50 +00:00
|
|
|
|
2005-01-13 15:18:02 +00:00
|
|
|
if (qglGetError())
|
2007-09-23 15:28:06 +00:00
|
|
|
Con_Printf(CON_ERROR "GL Error initing shader object\n");
|
2010-07-11 02:22:39 +00:00
|
|
|
#endif
|
2006-03-14 09:20:07 +00:00
|
|
|
}
|
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
void GL_InitFisheyeFov(void)
|
|
|
|
{
|
|
|
|
char *vshader = "\
|
|
|
|
varying vec2 texcoord;\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
|
|
|
texcoord = gl_MultiTexCoord0.xy;\
|
|
|
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\
|
|
|
|
}";
|
|
|
|
char *fisheyefshader = "\
|
|
|
|
uniform samplerCube source;\
|
|
|
|
varying vec2 texcoord;\
|
|
|
|
uniform float fov;\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
|
|
|
vec3 tc; \
|
|
|
|
vec2 d; \
|
|
|
|
vec2 ang; \
|
|
|
|
d = texcoord; \
|
|
|
|
ang.x = sqrt(d.x*d.x+d.y*d.y)*fov; \
|
|
|
|
ang.y = -atan(d.y, d.x); \
|
|
|
|
tc.x = sin(ang.x) * cos(ang.y); \
|
|
|
|
tc.y = sin(ang.x) * sin(ang.y); \
|
|
|
|
tc.z = cos(ang.x); \
|
|
|
|
gl_FragColor = textureCube(source, tc);\
|
|
|
|
}";
|
|
|
|
|
|
|
|
char *panoramafshader = "\
|
|
|
|
uniform samplerCube source;\
|
|
|
|
varying vec2 texcoord;\
|
|
|
|
uniform float fov;\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
|
|
|
vec3 tc; \
|
|
|
|
float ang; \
|
|
|
|
ang = texcoord.x*fov; \
|
|
|
|
tc.x = sin(ang); \
|
|
|
|
tc.y = -texcoord.y; \
|
|
|
|
tc.z = cos(ang); \
|
|
|
|
gl_FragColor = textureCube(source, tc);\
|
|
|
|
}";
|
|
|
|
|
|
|
|
scenepp_fisheye_program = GLSlang_CreateProgram(NULL, vshader, fisheyefshader);
|
|
|
|
if (scenepp_fisheye_program)
|
|
|
|
{
|
|
|
|
GLSlang_UseProgram(scenepp_fisheye_program);
|
|
|
|
GLSlang_SetUniform1i(GLSlang_GetUniformLocation(scenepp_fisheye_program, "source"), 0);
|
|
|
|
scenepp_fisheye_parm_fov = GLSlang_GetUniformLocation(scenepp_fisheye_program, "fov");
|
|
|
|
GLSlang_UseProgram(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
scenepp_panorama_program = GLSlang_CreateProgram(NULL, vshader, panoramafshader);
|
|
|
|
if (scenepp_panorama_program)
|
|
|
|
{
|
|
|
|
GLSlang_UseProgram(scenepp_panorama_program);
|
|
|
|
GLSlang_SetUniform1i(GLSlang_GetUniformLocation(scenepp_panorama_program, "source"), 0);
|
|
|
|
scenepp_panorama_parm_fov = GLSlang_GetUniformLocation(scenepp_panorama_program, "fov");
|
|
|
|
GLSlang_UseProgram(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-14 09:20:07 +00:00
|
|
|
void GL_InitSceneProcessingShaders_MenuTint(void)
|
|
|
|
{
|
|
|
|
char *vshader = "\
|
|
|
|
varying vec2 texcoord;\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
|
|
|
texcoord = gl_MultiTexCoord0.xy;\
|
|
|
|
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\
|
|
|
|
}";
|
|
|
|
char *fshader = "\
|
|
|
|
varying vec2 texcoord;\
|
|
|
|
uniform vec3 colorparam;\
|
|
|
|
uniform sampler2D source;\
|
|
|
|
uniform int invert;\
|
|
|
|
const vec3 lumfactors = vec3(0.299, 0.587, 0.114);\
|
|
|
|
const vec3 invertvec = vec3(1.0, 1.0, 1.0);\
|
|
|
|
void main(void)\
|
|
|
|
{\
|
|
|
|
vec3 texcolor = texture2D(source, texcoord).rgb;\
|
|
|
|
float luminance = dot(lumfactors, texcolor);\
|
|
|
|
texcolor = vec3(luminance, luminance, luminance);\
|
|
|
|
texcolor *= colorparam;\
|
|
|
|
texcolor = invert > 0 ? (invertvec - texcolor) : texcolor;\
|
|
|
|
gl_FragColor = vec4(texcolor, 1.0);\
|
|
|
|
}";
|
|
|
|
|
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("GL Error before initing shader object\n");
|
|
|
|
|
|
|
|
scenepp_mt_program = GLSlang_CreateProgram(NULL, vshader, fshader);
|
|
|
|
|
|
|
|
if (!scenepp_mt_program)
|
|
|
|
return;
|
|
|
|
|
|
|
|
scenepp_mt_parm_texture0i = GLSlang_GetUniformLocation(scenepp_mt_program, "source");
|
|
|
|
scenepp_mt_parm_colorf = GLSlang_GetUniformLocation(scenepp_mt_program, "colorparam");
|
|
|
|
scenepp_mt_parm_inverti = GLSlang_GetUniformLocation(scenepp_mt_program, "invert");
|
|
|
|
|
|
|
|
GLSlang_UseProgram(scenepp_mt_program);
|
|
|
|
GLSlang_SetUniform1i(scenepp_mt_parm_texture0i, 0);
|
|
|
|
|
|
|
|
GLSlang_UseProgram(0);
|
|
|
|
|
|
|
|
if (qglGetError())
|
2007-09-23 15:28:06 +00:00
|
|
|
Con_Printf(CON_ERROR "GL Error initing shader object\n");
|
2005-01-12 22:15:50 +00:00
|
|
|
}
|
2006-03-14 09:20:07 +00:00
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
void GL_InitSceneProcessingShaders (void)
|
|
|
|
{
|
2010-03-25 22:56:11 +00:00
|
|
|
if (gl_config.arb_shader_objects)
|
|
|
|
{
|
|
|
|
GL_InitSceneProcessingShaders_WaterWarp();
|
|
|
|
GL_InitFisheyeFov();
|
|
|
|
GL_InitSceneProcessingShaders_MenuTint();
|
|
|
|
}
|
2005-08-26 22:56:51 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-01-17 18:06:45 +00:00
|
|
|
#define PP_WARP_TEX_SIZE 64
|
|
|
|
#define PP_AMP_TEX_SIZE 64
|
|
|
|
#define PP_AMP_TEX_BORDER 4
|
|
|
|
void GL_SetupSceneProcessingTextures (void)
|
|
|
|
{
|
|
|
|
int i, x, y;
|
|
|
|
unsigned char pp_warp_tex[PP_WARP_TEX_SIZE*PP_WARP_TEX_SIZE*3];
|
|
|
|
unsigned char pp_edge_tex[PP_AMP_TEX_SIZE*PP_AMP_TEX_SIZE*3];
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
scenepp_fisheye_texture = r_nulltex;
|
2009-07-19 18:13:03 +00:00
|
|
|
|
2009-06-21 17:45:33 +00:00
|
|
|
sceneblur_texture = GL_AllocNewTexture();
|
2005-05-27 08:24:31 +00:00
|
|
|
|
2005-02-12 18:56:04 +00:00
|
|
|
if (!gl_config.arb_shader_objects)
|
|
|
|
return;
|
|
|
|
|
2009-06-21 17:45:33 +00:00
|
|
|
scenepp_texture = GL_AllocNewTexture();
|
|
|
|
scenepp_texture_warp = GL_AllocNewTexture();
|
|
|
|
scenepp_texture_edge = GL_AllocNewTexture();
|
2005-01-17 18:06:45 +00:00
|
|
|
|
2009-07-20 02:50:00 +00:00
|
|
|
// init warp texture - this specifies offset in
|
2005-01-17 18:06:45 +00:00
|
|
|
for (y=0; y<PP_WARP_TEX_SIZE; y++)
|
|
|
|
{
|
|
|
|
for (x=0; x<PP_WARP_TEX_SIZE; x++)
|
|
|
|
{
|
|
|
|
float fx, fy;
|
|
|
|
|
|
|
|
i = (x + y*PP_WARP_TEX_SIZE) * 3;
|
|
|
|
|
|
|
|
fx = sin(((double)y / PP_WARP_TEX_SIZE) * M_PI * 2);
|
|
|
|
fy = cos(((double)x / PP_WARP_TEX_SIZE) * M_PI * 2);
|
|
|
|
|
|
|
|
pp_warp_tex[i ] = (fx+1.0f)*127.0f;
|
|
|
|
pp_warp_tex[i+1] = (fy+1.0f)*127.0f;
|
|
|
|
pp_warp_tex[i+2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GL_Bind(scenepp_texture_warp);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
2005-02-12 18:56:04 +00:00
|
|
|
qglTexImage2D(GL_TEXTURE_2D, 0, 3, PP_WARP_TEX_SIZE, PP_WARP_TEX_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, pp_warp_tex);
|
2005-01-17 18:06:45 +00:00
|
|
|
|
|
|
|
// TODO: init edge texture - this is ampscale * 2, with ampscale calculated
|
2009-07-20 02:50:00 +00:00
|
|
|
// init warp texture - this specifies offset in
|
2005-01-17 18:06:45 +00:00
|
|
|
for (y=0; y<PP_AMP_TEX_SIZE; y++)
|
|
|
|
{
|
|
|
|
for (x=0; x<PP_AMP_TEX_SIZE; x++)
|
|
|
|
{
|
|
|
|
float fx = 1, fy = 1;
|
|
|
|
|
|
|
|
i = (x + y*PP_AMP_TEX_SIZE) * 3;
|
|
|
|
|
|
|
|
if (x < PP_AMP_TEX_BORDER)
|
|
|
|
{
|
|
|
|
fx = (float)x / PP_AMP_TEX_BORDER;
|
|
|
|
}
|
|
|
|
if (x > PP_AMP_TEX_SIZE - PP_AMP_TEX_BORDER)
|
|
|
|
{
|
|
|
|
fx = (PP_AMP_TEX_SIZE - (float)x) / PP_AMP_TEX_BORDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y < PP_AMP_TEX_BORDER)
|
|
|
|
{
|
|
|
|
fy = (float)y / PP_AMP_TEX_BORDER;
|
|
|
|
}
|
|
|
|
if (y > PP_AMP_TEX_SIZE - PP_AMP_TEX_BORDER)
|
|
|
|
{
|
|
|
|
fy = (PP_AMP_TEX_SIZE - (float)y) / PP_AMP_TEX_BORDER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fx < fy)
|
|
|
|
{
|
|
|
|
fy = fx;
|
|
|
|
}
|
|
|
|
|
|
|
|
pp_edge_tex[i ] = fy * 255;
|
|
|
|
pp_edge_tex[i+1] = 0;
|
|
|
|
pp_edge_tex[i+2] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GL_Bind(scenepp_texture_edge);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
2005-01-17 18:06:45 +00:00
|
|
|
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, PP_WARP_TEX_SIZE, PP_WARP_TEX_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, pp_edge_tex);
|
|
|
|
}
|
|
|
|
|
2010-07-18 08:42:59 +00:00
|
|
|
void R_RotateForEntity (entity_t *e, model_t *mod)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2004-11-17 18:13:33 +00:00
|
|
|
float m[16];
|
2005-08-07 18:08:13 +00:00
|
|
|
if (e->flags & Q2RF_WEAPONMODEL && r_refdef.currentplayernum>=0)
|
2005-02-12 18:56:04 +00:00
|
|
|
{ //rotate to view first
|
|
|
|
m[0] = cl.viewent[r_refdef.currentplayernum].axis[0][0];
|
|
|
|
m[1] = cl.viewent[r_refdef.currentplayernum].axis[0][1];
|
|
|
|
m[2] = cl.viewent[r_refdef.currentplayernum].axis[0][2];
|
|
|
|
m[3] = 0;
|
|
|
|
|
|
|
|
m[4] = cl.viewent[r_refdef.currentplayernum].axis[1][0];
|
|
|
|
m[5] = cl.viewent[r_refdef.currentplayernum].axis[1][1];
|
|
|
|
m[6] = cl.viewent[r_refdef.currentplayernum].axis[1][2];
|
|
|
|
m[7] = 0;
|
|
|
|
|
|
|
|
m[8] = cl.viewent[r_refdef.currentplayernum].axis[2][0];
|
|
|
|
m[9] = cl.viewent[r_refdef.currentplayernum].axis[2][1];
|
|
|
|
m[10] = cl.viewent[r_refdef.currentplayernum].axis[2][2];
|
|
|
|
m[11] = 0;
|
|
|
|
|
|
|
|
m[12] = cl.viewent[r_refdef.currentplayernum].origin[0];
|
|
|
|
m[13] = cl.viewent[r_refdef.currentplayernum].origin[1];
|
|
|
|
m[14] = cl.viewent[r_refdef.currentplayernum].origin[2];
|
|
|
|
m[15] = 1;
|
|
|
|
|
|
|
|
qglMultMatrixf(m);
|
|
|
|
}
|
|
|
|
|
2004-11-17 18:13:33 +00:00
|
|
|
m[0] = e->axis[0][0];
|
|
|
|
m[1] = e->axis[0][1];
|
|
|
|
m[2] = e->axis[0][2];
|
|
|
|
m[3] = 0;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2004-11-17 18:13:33 +00:00
|
|
|
m[4] = e->axis[1][0];
|
|
|
|
m[5] = e->axis[1][1];
|
|
|
|
m[6] = e->axis[1][2];
|
|
|
|
m[7] = 0;
|
|
|
|
|
|
|
|
m[8] = e->axis[2][0];
|
|
|
|
m[9] = e->axis[2][1];
|
|
|
|
m[10] = e->axis[2][2];
|
|
|
|
m[11] = 0;
|
|
|
|
|
|
|
|
m[12] = e->origin[0];
|
|
|
|
m[13] = e->origin[1];
|
|
|
|
m[14] = e->origin[2];
|
|
|
|
m[15] = 1;
|
|
|
|
|
2005-01-07 03:03:56 +00:00
|
|
|
qglMultMatrixf(m);
|
2010-07-18 08:42:59 +00:00
|
|
|
|
|
|
|
if (!mod)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (e->scale != 1 && e->scale != 0) //hexen 2 stuff
|
|
|
|
{
|
|
|
|
float tmatrix[3][4];
|
|
|
|
vec3_t scale;
|
|
|
|
vec3_t scale_origin;
|
|
|
|
float xyfact, zfact, entScale;
|
|
|
|
scale[0] = (mod->maxs[0]-mod->mins[0])/255;
|
|
|
|
scale[1] = (mod->maxs[1]-mod->mins[1])/255;
|
|
|
|
scale[2] = (mod->maxs[2]-mod->mins[2])/255;
|
|
|
|
scale_origin[0] = mod->mins[0];
|
|
|
|
scale_origin[1] = mod->mins[1];
|
|
|
|
scale_origin[2] = mod->mins[2];
|
|
|
|
|
|
|
|
|
|
|
|
entScale = (float)e->scale;
|
|
|
|
switch(e->drawflags&SCALE_TYPE_MASKIN)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SCALE_TYPE_UNIFORM:
|
|
|
|
tmatrix[0][0] = scale[0]*entScale;
|
|
|
|
tmatrix[1][1] = scale[1]*entScale;
|
|
|
|
tmatrix[2][2] = scale[2]*entScale;
|
|
|
|
xyfact = zfact = (entScale-1.0)*127.95;
|
|
|
|
break;
|
|
|
|
case SCALE_TYPE_XYONLY:
|
|
|
|
tmatrix[0][0] = scale[0]*entScale;
|
|
|
|
tmatrix[1][1] = scale[1]*entScale;
|
|
|
|
tmatrix[2][2] = scale[2];
|
|
|
|
xyfact = (entScale-1.0)*127.95;
|
|
|
|
zfact = 1.0;
|
|
|
|
break;
|
|
|
|
case SCALE_TYPE_ZONLY:
|
|
|
|
tmatrix[0][0] = scale[0];
|
|
|
|
tmatrix[1][1] = scale[1];
|
|
|
|
tmatrix[2][2] = scale[2]*entScale;
|
|
|
|
xyfact = 1.0;
|
|
|
|
zfact = (entScale-1.0)*127.95;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch(currententity->drawflags&SCALE_ORIGIN_MASKIN)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case SCALE_ORIGIN_CENTER:
|
|
|
|
tmatrix[0][3] = scale_origin[0]-scale[0]*xyfact;
|
|
|
|
tmatrix[1][3] = scale_origin[1]-scale[1]*xyfact;
|
|
|
|
tmatrix[2][3] = scale_origin[2]-scale[2]*zfact;
|
|
|
|
break;
|
|
|
|
case SCALE_ORIGIN_BOTTOM:
|
|
|
|
tmatrix[0][3] = scale_origin[0]-scale[0]*xyfact;
|
|
|
|
tmatrix[1][3] = scale_origin[1]-scale[1]*xyfact;
|
|
|
|
tmatrix[2][3] = scale_origin[2];
|
|
|
|
break;
|
|
|
|
case SCALE_ORIGIN_TOP:
|
|
|
|
tmatrix[0][3] = scale_origin[0]-scale[0]*xyfact;
|
|
|
|
tmatrix[1][3] = scale_origin[1]-scale[1]*xyfact;
|
|
|
|
tmatrix[2][3] = scale_origin[2]-scale[2]*zfact*2.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
{
|
|
|
|
tmatrix[0][0] = scale[0];
|
|
|
|
tmatrix[1][1] = scale[1];
|
|
|
|
tmatrix[2][2] = scale[2];
|
|
|
|
tmatrix[0][3] = scale_origin[0];
|
|
|
|
tmatrix[1][3] = scale_origin[1];
|
|
|
|
tmatrix[2][3] = scale_origin[2];
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
qglTranslatef (tmatrix[0][3],tmatrix[1][3],tmatrix[2][3]);
|
|
|
|
qglScalef (tmatrix[0][0],tmatrix[1][1],tmatrix[2][2]);
|
|
|
|
|
|
|
|
qglScalef( 1/scale[0],
|
|
|
|
1/scale[1],
|
|
|
|
1/scale[2]);
|
|
|
|
qglTranslatef ( -scale_origin[0],
|
|
|
|
-scale_origin[1],
|
|
|
|
-scale_origin[2]);
|
|
|
|
}
|
|
|
|
else if (!strcmp(mod->name, "progs/eyes.mdl"))
|
|
|
|
{
|
|
|
|
// double size of eyes, since they are really hard to see in gl
|
|
|
|
qglTranslatef (0, 0, 0 - (22 + 8));
|
|
|
|
qglScalef (2, 2, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ruleset_allow_larger_models.ival && mod->clampscale != 1)
|
|
|
|
{ //possibly this should be on a per-frame basis, but that's a real pain to do
|
|
|
|
Con_DPrintf("Rescaling %s by %f\n", mod->name, mod->clampscale);
|
|
|
|
qglScalef(mod->clampscale, mod->clampscale, mod->clampscale);
|
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================
|
|
|
|
|
|
|
|
SPRITE MODELS
|
|
|
|
|
|
|
|
=============================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
R_DrawSpriteModel
|
|
|
|
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void R_DrawSpriteModel (entity_t *e)
|
|
|
|
{
|
|
|
|
vec3_t point;
|
2009-11-04 21:16:50 +00:00
|
|
|
mspriteframe_t *frame, genframe;
|
2004-08-22 22:29:09 +00:00
|
|
|
vec3_t forward, right, up;
|
|
|
|
msprite_t *psprite;
|
2009-08-08 11:09:35 +00:00
|
|
|
vec3_t sprorigin;
|
2009-11-04 21:16:50 +00:00
|
|
|
unsigned int fl;
|
|
|
|
unsigned int sprtype;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
static vec2_t texcoords[4]={{0, 0},{0,1},{1,1},{1,0}};
|
2009-11-04 21:16:50 +00:00
|
|
|
static index_t indexes[6] = {0, 1, 2, 0, 2, 3};
|
|
|
|
vecV_t vertcoords[4];
|
|
|
|
avec4_t colours[4];
|
|
|
|
mesh_t mesh;
|
|
|
|
|
2009-08-08 11:09:35 +00:00
|
|
|
|
|
|
|
if (e->flags & Q2RF_WEAPONMODEL && r_refdef.currentplayernum >= 0)
|
|
|
|
{
|
|
|
|
sprorigin[0] = cl.viewent[r_refdef.currentplayernum].origin[0];
|
|
|
|
sprorigin[1] = cl.viewent[r_refdef.currentplayernum].origin[1];
|
|
|
|
sprorigin[2] = cl.viewent[r_refdef.currentplayernum].origin[2];
|
|
|
|
VectorMA(sprorigin, e->origin[0], cl.viewent[r_refdef.currentplayernum].axis[0], sprorigin);
|
|
|
|
VectorMA(sprorigin, e->origin[1], cl.viewent[r_refdef.currentplayernum].axis[1], sprorigin);
|
|
|
|
VectorMA(sprorigin, e->origin[2], cl.viewent[r_refdef.currentplayernum].axis[2], sprorigin);
|
|
|
|
VectorMA(sprorigin, 12, vpn, sprorigin);
|
|
|
|
|
|
|
|
e->flags |= RF_NODEPTHTEST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
VectorCopy(e->origin, sprorigin);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!e->model || e->forcedshader)
|
2005-08-26 22:56:51 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
genframe.shader = e->forcedshader;
|
|
|
|
genframe.up = genframe.left = -1;
|
|
|
|
genframe.down = genframe.right = 1;
|
|
|
|
sprtype = SPR_VP_PARALLEL;
|
|
|
|
frame = &genframe;
|
2005-08-26 22:56:51 +00:00
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// don't even bother culling, because it's just a single
|
|
|
|
// polygon without a surface cache
|
|
|
|
frame = R_GetSpriteFrame (e);
|
|
|
|
psprite = e->model->cache.data;
|
|
|
|
sprtype = psprite->type;
|
|
|
|
}
|
|
|
|
if (!frame->shader)
|
2005-08-26 22:56:51 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
switch(sprtype)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2005-08-26 22:56:51 +00:00
|
|
|
case SPR_ORIENTED:
|
|
|
|
// bullet marks on walls
|
|
|
|
AngleVectors (e->angles, forward, right, up);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SPR_FACING_UPRIGHT:
|
2004-08-22 22:29:09 +00:00
|
|
|
up[0] = 0;up[1] = 0;up[2]=1;
|
2009-08-08 11:09:35 +00:00
|
|
|
right[0] = sprorigin[1] - r_origin[1];
|
|
|
|
right[1] = -(sprorigin[0] - r_origin[0]);
|
2004-08-22 22:29:09 +00:00
|
|
|
right[2] = 0;
|
|
|
|
VectorNormalize (right);
|
2005-08-26 22:56:51 +00:00
|
|
|
break;
|
|
|
|
case SPR_VP_PARALLEL_UPRIGHT:
|
2004-08-22 22:29:09 +00:00
|
|
|
up[0] = 0;up[1] = 0;up[2]=1;
|
|
|
|
VectorCopy (vright, right);
|
2005-08-26 22:56:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case SPR_VP_PARALLEL:
|
|
|
|
//normal sprite
|
2004-08-22 22:29:09 +00:00
|
|
|
VectorCopy(vup, up);
|
|
|
|
VectorCopy(vright, right);
|
2005-08-26 22:56:51 +00:00
|
|
|
break;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2005-08-26 22:56:51 +00:00
|
|
|
up[0]*=e->scale;
|
|
|
|
up[1]*=e->scale;
|
|
|
|
up[2]*=e->scale;
|
|
|
|
right[0]*=e->scale;
|
|
|
|
right[1]*=e->scale;
|
|
|
|
right[2]*=e->scale;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
Vector4Copy(e->shaderRGBAf, colours[0]);
|
|
|
|
Vector4Copy(e->shaderRGBAf, colours[1]);
|
|
|
|
Vector4Copy(e->shaderRGBAf, colours[2]);
|
|
|
|
Vector4Copy(e->shaderRGBAf, colours[3]);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
fl = 0;
|
|
|
|
if (e->flags & Q2RF_ADDITIVE)
|
|
|
|
fl |= BEF_FORCEADDITIVE;
|
|
|
|
if (e->shaderRGBAf[3]<1 || gl_blendsprites.value)
|
|
|
|
fl |= BEF_FORCETRANSPARENT;
|
|
|
|
if (e->flags & RF_NODEPTHTEST)
|
|
|
|
fl |= BEF_FORCENODEPTH;
|
|
|
|
BE_SelectMode(BEM_STANDARD, fl);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-08-08 11:09:35 +00:00
|
|
|
VectorMA (sprorigin, frame->down, up, point);
|
2009-11-04 21:16:50 +00:00
|
|
|
VectorMA (point, frame->left, right, vertcoords[0]);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-08-08 11:09:35 +00:00
|
|
|
VectorMA (sprorigin, frame->up, up, point);
|
2009-11-04 21:16:50 +00:00
|
|
|
VectorMA (point, frame->left, right, vertcoords[1]);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-08-08 11:09:35 +00:00
|
|
|
VectorMA (sprorigin, frame->up, up, point);
|
2009-11-04 21:16:50 +00:00
|
|
|
VectorMA (point, frame->right, right, vertcoords[2]);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-08-08 11:09:35 +00:00
|
|
|
VectorMA (sprorigin, frame->down, up, point);
|
2009-11-04 21:16:50 +00:00
|
|
|
VectorMA (point, frame->right, right, vertcoords[3]);
|
2005-04-16 16:21:27 +00:00
|
|
|
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
memset(&mesh, 0, sizeof(mesh));
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.vbofirstelement = 0;
|
|
|
|
mesh.vbofirstvert = 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
mesh.xyz_array = vertcoords;
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.indexes = indexes;
|
2009-11-04 21:16:50 +00:00
|
|
|
mesh.numindexes = sizeof(indexes)/sizeof(indexes[0]);
|
|
|
|
mesh.colors4f_array = colours;
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.lmst_array = NULL;
|
|
|
|
mesh.normals_array = NULL;
|
2009-11-04 21:16:50 +00:00
|
|
|
mesh.numvertexes = 4;
|
|
|
|
mesh.st_array = texcoords;
|
|
|
|
mesh.istrifan = true;
|
2010-07-11 02:22:39 +00:00
|
|
|
BE_DrawMesh_Single(frame->shader, &mesh, NULL, &frame->shader->defaulttextures);
|
2009-07-25 11:05:06 +00:00
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
//==================================================================================
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2008-12-23 02:55:20 +00:00
|
|
|
void GLR_DrawSprite(int count, void **e, void *parm)
|
2005-07-14 01:57:34 +00:00
|
|
|
{
|
2008-12-23 02:55:20 +00:00
|
|
|
while(count--)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
#pragma message("this needs merging or q3 railgun will lag like hell")
|
2010-04-09 10:48:22 +00:00
|
|
|
currententity = e[count];
|
2005-07-14 01:57:34 +00:00
|
|
|
|
2008-12-23 02:55:20 +00:00
|
|
|
R_DrawSpriteModel (currententity);
|
|
|
|
}
|
2005-07-14 01:57:34 +00:00
|
|
|
}
|
2009-07-25 11:05:06 +00:00
|
|
|
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef Q3CLIENT
|
2009-07-25 11:05:06 +00:00
|
|
|
|
|
|
|
//q3 lightning gun
|
|
|
|
void R_DrawLightning(entity_t *e)
|
|
|
|
{
|
|
|
|
vec3_t v;
|
|
|
|
vec3_t dir, cr;
|
|
|
|
float scale = e->scale;
|
|
|
|
float length;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
vecV_t points[4];
|
2009-07-25 11:05:06 +00:00
|
|
|
vec2_t texcoords[4] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
|
2010-07-11 02:22:39 +00:00
|
|
|
static index_t indexarray[6] = {0, 1, 2, 0, 2, 3};
|
2009-07-25 11:05:06 +00:00
|
|
|
|
|
|
|
mesh_t mesh;
|
|
|
|
|
|
|
|
if (!e->forcedshader)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!scale)
|
|
|
|
scale = 10;
|
|
|
|
|
|
|
|
|
|
|
|
VectorSubtract(e->origin, e->oldorigin, dir);
|
|
|
|
length = Length(dir);
|
|
|
|
|
|
|
|
//this seems to be about right.
|
|
|
|
texcoords[2][0] = length/128;
|
|
|
|
texcoords[3][0] = length/128;
|
|
|
|
|
|
|
|
VectorSubtract(r_refdef.vieworg, e->origin, v);
|
|
|
|
CrossProduct(v, dir, cr);
|
|
|
|
VectorNormalize(cr);
|
|
|
|
|
|
|
|
VectorMA(e->origin, -scale/2, cr, points[0]);
|
|
|
|
VectorMA(e->origin, scale/2, cr, points[1]);
|
|
|
|
|
|
|
|
VectorSubtract(r_refdef.vieworg, e->oldorigin, v);
|
|
|
|
CrossProduct(v, dir, cr);
|
|
|
|
VectorNormalize(cr);
|
|
|
|
|
|
|
|
VectorMA(e->oldorigin, scale/2, cr, points[2]);
|
|
|
|
VectorMA(e->oldorigin, -scale/2, cr, points[3]);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
memset(&mesh, 0, sizeof(mesh));
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.vbofirstelement = 0;
|
|
|
|
mesh.vbofirstvert = 0;
|
|
|
|
mesh.xyz_array = points;
|
|
|
|
mesh.indexes = indexarray;
|
|
|
|
mesh.numindexes = sizeof(indexarray)/sizeof(indexarray[0]);
|
2009-11-04 21:16:50 +00:00
|
|
|
mesh.colors4f_array = NULL;
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.lmst_array = NULL;
|
|
|
|
mesh.normals_array = NULL;
|
|
|
|
mesh.numvertexes = 4;
|
|
|
|
mesh.st_array = texcoords;
|
2010-07-11 02:22:39 +00:00
|
|
|
BE_DrawMesh_Single(e->forcedshader, &mesh, NULL, NULL);
|
2009-07-25 11:05:06 +00:00
|
|
|
}
|
|
|
|
//q3 railgun beam
|
|
|
|
void R_DrawRailCore(entity_t *e)
|
|
|
|
{
|
|
|
|
vec3_t v;
|
|
|
|
vec3_t dir, cr;
|
|
|
|
float scale = e->scale;
|
|
|
|
float length;
|
|
|
|
|
|
|
|
mesh_t mesh;
|
2009-11-04 21:16:50 +00:00
|
|
|
vecV_t points[4];
|
2009-07-25 11:05:06 +00:00
|
|
|
vec2_t texcoords[4] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
|
2010-07-11 02:22:39 +00:00
|
|
|
static index_t indexarray[6] = {0, 1, 2, 0, 2, 3};
|
2009-11-04 21:16:50 +00:00
|
|
|
vec4_t colors[4];
|
2009-07-25 11:05:06 +00:00
|
|
|
|
|
|
|
if (!e->forcedshader)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!scale)
|
|
|
|
scale = 10;
|
|
|
|
|
|
|
|
|
|
|
|
VectorSubtract(e->origin, e->oldorigin, dir);
|
|
|
|
length = Length(dir);
|
|
|
|
|
|
|
|
//this seems to be about right.
|
|
|
|
texcoords[2][0] = length/128;
|
|
|
|
texcoords[3][0] = length/128;
|
|
|
|
|
|
|
|
VectorSubtract(r_refdef.vieworg, e->origin, v);
|
|
|
|
CrossProduct(v, dir, cr);
|
|
|
|
VectorNormalize(cr);
|
|
|
|
|
|
|
|
VectorMA(e->origin, -scale/2, cr, points[0]);
|
|
|
|
VectorMA(e->origin, scale/2, cr, points[1]);
|
|
|
|
|
|
|
|
VectorSubtract(r_refdef.vieworg, e->oldorigin, v);
|
|
|
|
CrossProduct(v, dir, cr);
|
|
|
|
VectorNormalize(cr);
|
|
|
|
|
|
|
|
VectorMA(e->oldorigin, scale/2, cr, points[2]);
|
|
|
|
VectorMA(e->oldorigin, -scale/2, cr, points[3]);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
Vector4Copy(e->shaderRGBAf, colors[0]);
|
|
|
|
Vector4Copy(e->shaderRGBAf, colors[1]);
|
|
|
|
Vector4Copy(e->shaderRGBAf, colors[2]);
|
|
|
|
Vector4Copy(e->shaderRGBAf, colors[3]);
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
memset(&mesh, 0, sizeof(mesh));
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.vbofirstelement = 0;
|
|
|
|
mesh.vbofirstvert = 0;
|
|
|
|
mesh.xyz_array = points;
|
|
|
|
mesh.indexes = indexarray;
|
|
|
|
mesh.numindexes = sizeof(indexarray)/sizeof(indexarray[0]);
|
2009-11-04 21:16:50 +00:00
|
|
|
mesh.colors4f_array = (vec4_t*)colors;
|
2009-07-25 11:05:06 +00:00
|
|
|
mesh.lmst_array = NULL;
|
|
|
|
mesh.normals_array = NULL;
|
|
|
|
mesh.numvertexes = 4;
|
|
|
|
mesh.st_array = texcoords;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
BE_DrawMesh_Single(e->forcedshader, &mesh, NULL, NULL);
|
2009-07-25 11:05:06 +00:00
|
|
|
}
|
2009-07-25 13:49:33 +00:00
|
|
|
#endif
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
/*quick test: map bunk1 ware1 */
|
|
|
|
void R_DrawBeam(entity_t *e)
|
|
|
|
{
|
|
|
|
float r, g, b;
|
|
|
|
|
|
|
|
vec3_t dir, v, cr;
|
|
|
|
vecV_t points[4];
|
|
|
|
float length, scale;
|
|
|
|
static byte_vec4_t colours[4];
|
|
|
|
static vec2_t texcoords[4] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}};
|
|
|
|
static index_t indexarray[6] = {0, 1, 2, 0, 2, 3};
|
|
|
|
mesh_t mesh;
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
shader_t *beamshader;
|
|
|
|
beamshader = R_RegisterShader("q2beam",
|
|
|
|
"{\n"
|
|
|
|
"{\n"
|
|
|
|
"map $whiteimage\n"
|
|
|
|
"rgbgen vertex\n"
|
|
|
|
"alphagen vertex\n"
|
|
|
|
"blendfunc blend\n"
|
|
|
|
"}\n"
|
|
|
|
"}\n"
|
|
|
|
);
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
VectorSubtract(e->origin, e->oldorigin, dir);
|
|
|
|
length = Length(dir);
|
|
|
|
|
|
|
|
scale = e->scale;
|
|
|
|
if (!scale)
|
|
|
|
scale = 1;
|
|
|
|
scale *= e->framestate.g[FS_REG].frame[0];
|
|
|
|
if (!scale)
|
|
|
|
scale = 6;
|
|
|
|
|
|
|
|
scale/= 2;
|
|
|
|
|
|
|
|
VectorSubtract(r_refdef.vieworg, e->origin, v);
|
|
|
|
CrossProduct(v, dir, cr);
|
|
|
|
VectorNormalize(cr);
|
|
|
|
VectorMA(e->origin, scale, cr, points[0]);
|
|
|
|
VectorMA(e->origin, -scale, cr, points[1]);
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
VectorSubtract(r_refdef.vieworg, e->oldorigin, v);
|
|
|
|
CrossProduct(v, dir, cr);
|
|
|
|
VectorNormalize(cr);
|
|
|
|
VectorMA(e->oldorigin, -scale, cr, points[2]);
|
|
|
|
VectorMA(e->oldorigin, scale, cr, points[3]);
|
|
|
|
|
|
|
|
r = ( d_8to24rgbtable[e->skinnum & 0xFF] ) & 0xFF;
|
|
|
|
g = ( d_8to24rgbtable[e->skinnum & 0xFF] >> 8 ) & 0xFF;
|
|
|
|
b = ( d_8to24rgbtable[e->skinnum & 0xFF] >> 16 ) & 0xFF;
|
|
|
|
|
|
|
|
r *= e->shaderRGBAf[0];
|
|
|
|
g *= e->shaderRGBAf[1];
|
|
|
|
b *= e->shaderRGBAf[2];
|
|
|
|
|
|
|
|
colours[0][0] = r;
|
|
|
|
colours[0][1] = g;
|
|
|
|
colours[0][2] = b;
|
|
|
|
colours[0][3] = 255*0.666;
|
|
|
|
*(int*)colours[1] = *(int*)colours[0];
|
|
|
|
*(int*)colours[2] = *(int*)colours[0];
|
|
|
|
*(int*)colours[3] = *(int*)colours[0];
|
|
|
|
|
|
|
|
memset(&mesh, 0, sizeof(mesh));
|
|
|
|
mesh.vbofirstelement = 0;
|
|
|
|
mesh.vbofirstvert = 0;
|
|
|
|
mesh.xyz_array = points;
|
|
|
|
mesh.indexes = indexarray;
|
|
|
|
mesh.numindexes = sizeof(indexarray)/sizeof(indexarray[0]);
|
|
|
|
mesh.colors4b_array = colours;
|
|
|
|
mesh.lmst_array = NULL;
|
|
|
|
mesh.normals_array = NULL;
|
|
|
|
mesh.numvertexes = sizeof(points)/sizeof(points[0]);
|
|
|
|
mesh.st_array = texcoords;
|
|
|
|
BE_DrawMesh_Single(beamshader, &mesh, NULL, &beamshader->defaulttextures);
|
|
|
|
}
|
2009-07-25 11:05:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_ShouldDraw
|
|
|
|
Ents are added to the list regardless.
|
|
|
|
This is where they're filtered (based on which view is currently being drawn).
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
qboolean R_ShouldDraw(entity_t *e)
|
|
|
|
{
|
|
|
|
if (e->flags & Q2RF_EXTERNALMODEL && !r_refdef.externalview)
|
|
|
|
return false;
|
|
|
|
if (!Cam_DrawPlayer(r_refdef.currentplayernum, e->keynum-1))
|
|
|
|
return false;
|
|
|
|
return true;
|
2009-07-25 11:05:06 +00:00
|
|
|
}
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_DrawEntitiesOnList
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
void GLR_DrawEntitiesOnList (void)
|
|
|
|
{
|
2005-09-21 01:21:35 +00:00
|
|
|
int i;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
if (!r_drawentities.value)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// draw sprites seperately, because of alpha blending
|
|
|
|
for (i=0 ; i<cl_numvisedicts ; i++)
|
|
|
|
{
|
|
|
|
currententity = &cl_visedicts[i];
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (!R_ShouldDraw(currententity))
|
2005-08-26 22:56:51 +00:00
|
|
|
continue;
|
2004-10-04 07:27:41 +00:00
|
|
|
|
2005-09-14 04:29:22 +00:00
|
|
|
|
2005-08-26 22:56:51 +00:00
|
|
|
switch (currententity->rtype)
|
|
|
|
{
|
|
|
|
case RT_SPRITE:
|
|
|
|
RQ_AddDistReorder(GLR_DrawSprite, currententity, NULL, currententity->origin);
|
2005-09-14 04:29:22 +00:00
|
|
|
// R_DrawSpriteModel(currententity);
|
|
|
|
continue;
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef Q3CLIENT
|
2005-09-14 04:29:22 +00:00
|
|
|
case RT_BEAM:
|
|
|
|
case RT_RAIL_RINGS:
|
|
|
|
case RT_LIGHTNING:
|
|
|
|
R_DrawLightning(currententity);
|
2005-08-26 22:56:51 +00:00
|
|
|
continue;
|
|
|
|
case RT_RAIL_CORE:
|
2005-09-14 04:29:22 +00:00
|
|
|
R_DrawRailCore(currententity);
|
2005-08-26 22:56:51 +00:00
|
|
|
continue;
|
2005-09-29 23:32:22 +00:00
|
|
|
#endif
|
2006-03-04 20:43:48 +00:00
|
|
|
case RT_MODEL: //regular model
|
|
|
|
break;
|
|
|
|
case RT_PORTALSURFACE:
|
|
|
|
continue; //this doesn't do anything anyway, does it?
|
|
|
|
default:
|
|
|
|
case RT_POLY: //these are a little painful, we need to do them some time... just not yet.
|
|
|
|
continue;
|
2005-08-26 22:56:51 +00:00
|
|
|
}
|
2005-03-18 06:14:33 +00:00
|
|
|
if (currententity->flags & Q2RF_BEAM)
|
2005-04-16 16:21:27 +00:00
|
|
|
{
|
|
|
|
R_DrawBeam(currententity);
|
2005-03-18 06:14:33 +00:00
|
|
|
continue;
|
2005-04-16 16:21:27 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
if (!currententity->model)
|
|
|
|
continue;
|
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
|
2005-09-08 22:52:46 +00:00
|
|
|
if (cl.lerpents && (cls.allow_anyparticles || currententity->visframe)) //allowed or static
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2005-08-06 22:39:28 +00:00
|
|
|
if (gl_part_flame.value)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2005-08-06 22:39:28 +00:00
|
|
|
if (currententity->model->engineflags & MDLF_ENGULPHS)
|
|
|
|
continue;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-21 03:19:46 +00:00
|
|
|
if (currententity->model->engineflags & MDLF_NOTREPLACEMENTS)
|
|
|
|
{
|
2008-02-24 19:20:51 +00:00
|
|
|
if (currententity->model->fromgame != fg_quake || currententity->model->type != mod_alias)
|
2008-02-21 03:19:46 +00:00
|
|
|
if (!ruleset_allow_sensative_texture_replacements.value)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
switch (currententity->model->type)
|
|
|
|
{
|
|
|
|
case mod_alias:
|
2005-08-26 22:56:51 +00:00
|
|
|
if (r_refdef.flags & Q2RDF_NOWORLDMODEL || !cl.worldmodel || cl.worldmodel->type != mod_brush || cl.worldmodel->fromgame == fg_doom)
|
2009-11-04 21:16:50 +00:00
|
|
|
R_DrawGAliasModel (currententity, BEM_STANDARD);
|
2004-08-22 22:29:09 +00:00
|
|
|
break;
|
2009-07-20 02:50:00 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
#ifdef HALFLIFEMODELS
|
|
|
|
case mod_halflife:
|
|
|
|
R_DrawHLModel (currententity);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case mod_brush:
|
2005-08-26 22:56:51 +00:00
|
|
|
if (!cl.worldmodel || cl.worldmodel->type != mod_brush || cl.worldmodel->fromgame == fg_doom)
|
2004-08-22 22:29:09 +00:00
|
|
|
PPL_BaseBModelTextures (currententity);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case mod_sprite:
|
2005-07-14 01:57:34 +00:00
|
|
|
RQ_AddDistReorder(GLR_DrawSprite, currententity, NULL, currententity->origin);
|
2005-08-26 22:56:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef TERRAIN
|
|
|
|
case mod_heightmap:
|
|
|
|
GL_DrawHeightmapModel(currententity);
|
|
|
|
break;
|
|
|
|
#endif
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-07-14 01:57:34 +00:00
|
|
|
default:
|
2004-08-22 22:29:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_SetupGL
|
|
|
|
=============
|
|
|
|
*/
|
|
|
|
void R_SetupGL (void)
|
|
|
|
{
|
|
|
|
float screenaspect;
|
|
|
|
int x, x2, y2, y, w, h;
|
2005-09-29 23:32:22 +00:00
|
|
|
|
|
|
|
float fov_x, fov_y;
|
2009-11-07 13:29:15 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (!r_refdef.recurse)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
|
|
|
|
VectorCopy (r_refdef.vieworg, r_origin);
|
2005-09-29 23:32:22 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
//
|
|
|
|
// set up viewpoint
|
|
|
|
//
|
|
|
|
x = r_refdef.vrect.x * vid.pixelwidth/(int)vid.width;
|
|
|
|
x2 = (r_refdef.vrect.x + r_refdef.vrect.width) * vid.pixelwidth/(int)vid.width;
|
|
|
|
y = (vid.height-r_refdef.vrect.y) * vid.pixelheight/(int)vid.height;
|
|
|
|
y2 = ((int)vid.height - (r_refdef.vrect.y + r_refdef.vrect.height)) * vid.pixelheight/(int)vid.height;
|
|
|
|
|
|
|
|
// fudge around because of frac screen scale
|
|
|
|
if (x > 0)
|
|
|
|
x--;
|
|
|
|
if (x2 < vid.pixelwidth)
|
|
|
|
x2++;
|
|
|
|
if (y2 < 0)
|
|
|
|
y2--;
|
|
|
|
if (y < vid.pixelheight)
|
|
|
|
y++;
|
|
|
|
|
|
|
|
w = x2 - x;
|
|
|
|
h = y - y2;
|
|
|
|
|
|
|
|
r_refdef.pxrect.x = x;
|
|
|
|
r_refdef.pxrect.y = y;
|
|
|
|
r_refdef.pxrect.width = w;
|
|
|
|
r_refdef.pxrect.height = h;
|
|
|
|
|
|
|
|
qglViewport (x, y2, w, h);
|
|
|
|
|
|
|
|
fov_x = r_refdef.fov_x;//+sin(cl.time)*5;
|
|
|
|
fov_y = r_refdef.fov_y;//-sin(cl.time+1)*5;
|
|
|
|
|
|
|
|
if (r_waterwarp.value<0 && r_viewleaf && r_viewleaf->contents <= Q1CONTENTS_WATER)
|
2005-07-14 01:57:34 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
fov_x *= 1 + (((sin(cl.time * 4.7) + 1) * 0.015) * r_waterwarp.value);
|
|
|
|
fov_y *= 1 + (((sin(cl.time * 3.0) + 1) * 0.015) * r_waterwarp.value);
|
2005-07-14 01:57:34 +00:00
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
|
|
|
|
if (r_refdef.useperspective)
|
2005-07-14 01:57:34 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
int stencilshadows = 0;
|
|
|
|
#ifdef RTLIGHTS
|
|
|
|
stencilshadows |= r_shadow_realtime_dlight.ival && r_shadow_realtime_dlight_shadows.ival;
|
|
|
|
stencilshadows |= r_shadow_realtime_world.ival && r_shadow_realtime_world_shadows.ival;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((!stencilshadows || !gl_canstencil) && gl_maxdist.value>=100)//gl_nv_range_clamp)
|
|
|
|
{
|
|
|
|
// yfov = 2*atan((float)r_refdef.vrect.height/r_refdef.vrect.width)*180/M_PI;
|
|
|
|
// 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;
|
|
|
|
// MYgluPerspective (yfov, screenaspect, 4, 4096);
|
2009-07-05 18:45:53 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
Matrix4_Projection_Far(r_refdef.m_projection, fov_x, fov_y, gl_mindist.value, gl_maxdist.value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Matrix4_Projection_Inf(r_refdef.m_projection, fov_x, fov_y, gl_mindist.value);
|
|
|
|
}
|
2005-07-14 01:57:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
if (gl_maxdist.value>=1)
|
|
|
|
Matrix4_Orthographic(r_refdef.m_projection, -fov_x/2, fov_x/2, fov_y/2, -fov_y/2, -gl_maxdist.value, gl_maxdist.value);
|
|
|
|
else
|
|
|
|
Matrix4_Orthographic(r_refdef.m_projection, 0, r_refdef.vrect.width, 0, r_refdef.vrect.height, -9999, 9999);
|
2005-07-14 01:57:34 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
Matrix4_ModelViewMatrixFromAxis(r_refdef.m_view, vpn, vright, vup, r_refdef.vieworg);
|
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglLoadMatrixf(r_refdef.m_projection);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglLoadMatrixf(r_refdef.m_view);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (gl_dither.ival)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2005-01-07 03:03:56 +00:00
|
|
|
qglEnable(GL_DITHER);
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-07 03:03:56 +00:00
|
|
|
qglDisable(GL_DITHER);
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
R_RenderScene
|
|
|
|
|
|
|
|
r_refdef must be set before the first call
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void R_RenderScene (void)
|
|
|
|
{
|
|
|
|
qboolean GLR_DoomWorld(void);
|
2005-06-14 04:52:10 +00:00
|
|
|
|
2006-03-06 01:41:09 +00:00
|
|
|
if (!cl.worldmodel || (!cl.worldmodel->nodes && cl.worldmodel->type != mod_heightmap))
|
2005-06-14 04:52:10 +00:00
|
|
|
r_refdef.flags |= Q2RDF_NOWORLDMODEL;
|
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
TRACE(("dbg: calling R_SetupGL\n"));
|
2004-08-22 22:29:09 +00:00
|
|
|
R_SetupGL ();
|
|
|
|
|
2005-07-01 19:23:00 +00:00
|
|
|
TRACE(("dbg: calling R_SetFrustrum\n"));
|
2010-07-11 02:22:39 +00:00
|
|
|
R_SetFrustum (r_refdef.m_projection, r_refdef.m_view);
|
2005-07-01 19:23:00 +00:00
|
|
|
|
2005-08-07 18:08:13 +00:00
|
|
|
if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL))
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
#ifdef DOOMWADS
|
|
|
|
if (!GLR_DoomWorld ())
|
|
|
|
#endif
|
|
|
|
{
|
2004-10-19 16:10:14 +00:00
|
|
|
TRACE(("dbg: calling R_DrawWorld\n"));
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_DrawWorld (); // adds static entities to the list
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
S_ExtraUpdate (); // don't let sound get messed up if going slow
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
RQ_BeginFrame();
|
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
TRACE(("dbg: calling GLR_DrawEntitiesOnList\n"));
|
2004-08-22 22:29:09 +00:00
|
|
|
GLR_DrawEntitiesOnList ();
|
|
|
|
|
|
|
|
// R_DrawDecals();
|
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
TRACE(("dbg: calling R_RenderDlights\n"));
|
2007-05-25 22:16:29 +00:00
|
|
|
GLR_RenderDlights ();
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-08-07 18:08:13 +00:00
|
|
|
if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL))
|
2004-10-19 16:10:14 +00:00
|
|
|
{
|
|
|
|
TRACE(("dbg: calling R_DrawParticles\n"));
|
2005-03-10 03:55:18 +00:00
|
|
|
P_DrawParticles ();
|
2004-10-19 16:10:14 +00:00
|
|
|
}
|
2009-11-17 00:15:44 +00:00
|
|
|
RQ_RenderBatchClear();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
/*generates a new modelview matrix, as well as vpn vectors*/
|
|
|
|
static void R_MirrorMatrix(plane_t *plane)
|
|
|
|
{
|
|
|
|
float mirror[16];
|
|
|
|
float view[16];
|
|
|
|
float result[16];
|
|
|
|
|
|
|
|
vec3_t pnorm;
|
|
|
|
VectorNegate(plane->normal, pnorm);
|
|
|
|
|
|
|
|
mirror[0] = 1-2*pnorm[0]*pnorm[0];
|
|
|
|
mirror[1] = -2*pnorm[0]*pnorm[1];
|
|
|
|
mirror[2] = -2*pnorm[0]*pnorm[2];
|
|
|
|
mirror[3] = 0;
|
|
|
|
|
|
|
|
mirror[4] = -2*pnorm[1]*pnorm[0];
|
|
|
|
mirror[5] = 1-2*pnorm[1]*pnorm[1];
|
|
|
|
mirror[6] = -2*pnorm[1]*pnorm[2] ;
|
|
|
|
mirror[7] = 0;
|
|
|
|
|
|
|
|
mirror[8] = -2*pnorm[2]*pnorm[0];
|
|
|
|
mirror[9] = -2*pnorm[2]*pnorm[1];
|
|
|
|
mirror[10] = 1-2*pnorm[2]*pnorm[2];
|
|
|
|
mirror[11] = 0;
|
|
|
|
|
|
|
|
mirror[12] = -2*pnorm[0]*plane->dist;
|
|
|
|
mirror[13] = -2*pnorm[1]*plane->dist;
|
|
|
|
mirror[14] = -2*pnorm[2]*plane->dist;
|
|
|
|
mirror[15] = 1;
|
|
|
|
|
|
|
|
view[0] = vpn[0];
|
|
|
|
view[1] = vpn[1];
|
|
|
|
view[2] = vpn[2];
|
|
|
|
view[3] = 0;
|
|
|
|
|
|
|
|
view[4] = -vright[0];
|
|
|
|
view[5] = -vright[1];
|
|
|
|
view[6] = -vright[2];
|
|
|
|
view[7] = 0;
|
|
|
|
|
|
|
|
view[8] = vup[0];
|
|
|
|
view[9] = vup[1];
|
|
|
|
view[10] = vup[2];
|
|
|
|
view[11] = 0;
|
|
|
|
|
|
|
|
view[12] = r_refdef.vieworg[0];
|
|
|
|
view[13] = r_refdef.vieworg[1];
|
|
|
|
view[14] = r_refdef.vieworg[2];
|
|
|
|
view[15] = 1;
|
|
|
|
|
|
|
|
VectorMA(r_refdef.vieworg, 0.25, plane->normal, r_refdef.pvsorigin);
|
|
|
|
|
|
|
|
Matrix4_Multiply(mirror, view, result);
|
|
|
|
|
|
|
|
vpn[0] = result[0];
|
|
|
|
vpn[1] = result[1];
|
|
|
|
vpn[2] = result[2];
|
|
|
|
|
|
|
|
vright[0] = -result[4];
|
|
|
|
vright[1] = -result[5];
|
|
|
|
vright[2] = -result[6];
|
|
|
|
|
|
|
|
vup[0] = result[8];
|
|
|
|
vup[1] = result[9];
|
|
|
|
vup[2] = result[10];
|
|
|
|
|
|
|
|
r_refdef.vieworg[0] = result[12];
|
|
|
|
r_refdef.vieworg[1] = result[13];
|
|
|
|
r_refdef.vieworg[2] = result[14];
|
|
|
|
}
|
|
|
|
static entity_t *R_NearestPortal(plane_t *plane)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
entity_t *best = NULL;
|
|
|
|
float dist, bestd = 0;
|
|
|
|
for (i = 0; i < cl_numvisedicts; i++)
|
|
|
|
{
|
|
|
|
if (cl_visedicts[i].rtype == RT_PORTALSURFACE)
|
|
|
|
{
|
|
|
|
dist = DotProduct(cl_visedicts[i].origin, plane->normal)-plane->dist;
|
|
|
|
dist = fabs(dist);
|
|
|
|
if (dist < 64 && (!best || dist < bestd))
|
|
|
|
best = &cl_visedicts[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best;
|
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
static void TransformCoord(vec3_t in, vec3_t planea[3], vec3_t planeo, vec3_t viewa[3], vec3_t viewo, vec3_t result)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
vec3_t local;
|
|
|
|
vec3_t transformed;
|
|
|
|
float d;
|
|
|
|
|
|
|
|
local[0] = in[0] - planeo[0];
|
|
|
|
local[1] = in[1] - planeo[1];
|
|
|
|
local[2] = in[2] - planeo[2];
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
VectorClear(transformed);
|
|
|
|
for ( i = 0 ; i < 3 ; i++ )
|
|
|
|
{
|
|
|
|
d = DotProduct(local, planea[i]);
|
|
|
|
VectorMA(transformed, d, viewa[i], transformed);
|
|
|
|
}
|
|
|
|
|
|
|
|
result[0] = transformed[0] + viewo[0];
|
|
|
|
result[1] = transformed[1] + viewo[1];
|
|
|
|
result[2] = transformed[2] + viewo[2];
|
|
|
|
}
|
|
|
|
static void TransformDir(vec3_t in, vec3_t planea[3], vec3_t viewa[3], vec3_t result)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float d;
|
|
|
|
vec3_t tmp;
|
|
|
|
|
|
|
|
VectorCopy(in, tmp);
|
|
|
|
|
|
|
|
VectorClear(result);
|
|
|
|
for ( i = 0 ; i < 3 ; i++ )
|
|
|
|
{
|
|
|
|
d = DotProduct(tmp, planea[i]);
|
|
|
|
VectorMA(result, d, viewa[i], result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void R_DrawPortal(batch_t *batch)
|
|
|
|
{
|
|
|
|
entity_t *view;
|
|
|
|
GLdouble glplane[4];
|
|
|
|
plane_t plane;
|
|
|
|
refdef_t oldrefdef;
|
|
|
|
mesh_t *mesh = batch->mesh[batch->firstmesh];
|
|
|
|
|
|
|
|
if (r_refdef.recurse)
|
|
|
|
return;
|
|
|
|
|
|
|
|
VectorCopy(mesh->normals_array[0], plane.normal);
|
|
|
|
plane.dist = DotProduct(mesh->xyz_array[0], plane.normal);
|
|
|
|
|
|
|
|
//if we're too far away from the surface, don't draw anything
|
|
|
|
if (batch->shader->flags & SHADER_AGEN_PORTAL)
|
|
|
|
{
|
|
|
|
/*there's a portal alpha blend on that surface, that fades out after this distance*/
|
|
|
|
if (DotProduct(r_refdef.vieworg, plane.normal)-plane.dist > batch->shader->portaldist)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//if we're behind it, then also don't draw anything.
|
|
|
|
if (DotProduct(r_refdef.vieworg, plane.normal)-plane.dist < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
view = R_NearestPortal(&plane);
|
|
|
|
//if (!view)
|
|
|
|
// return;
|
|
|
|
|
|
|
|
oldrefdef = r_refdef;
|
|
|
|
r_refdef.recurse = true;
|
|
|
|
|
|
|
|
r_refdef.externalview = true;
|
|
|
|
|
|
|
|
if (!view || VectorCompare(view->origin, view->oldorigin))
|
|
|
|
{
|
|
|
|
r_refdef.flipcull ^= true;
|
|
|
|
R_MirrorMatrix(&plane);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float d;
|
|
|
|
vec3_t paxis[3], porigin, vaxis[3], vorg;
|
|
|
|
void PerpendicularVector( vec3_t dst, const vec3_t src );
|
|
|
|
|
|
|
|
/*calculate where the surface is meant to be*/
|
|
|
|
VectorCopy(mesh->normals_array[0], paxis[0]);
|
|
|
|
PerpendicularVector(paxis[1], paxis[1]);
|
|
|
|
CrossProduct(paxis[0], paxis[1], paxis[2]);
|
|
|
|
d = DotProduct(view->origin, plane.normal) - plane.dist;
|
|
|
|
VectorMA(view->origin, -d, paxis[0], porigin);
|
|
|
|
|
|
|
|
/*grab the camera origin*/
|
|
|
|
VectorNegate(view->axis[0], vaxis[0]);
|
|
|
|
VectorNegate(view->axis[1], vaxis[1]);
|
|
|
|
VectorCopy(view->axis[2], vaxis[2]);
|
|
|
|
VectorCopy(view->oldorigin, vorg);
|
|
|
|
|
|
|
|
VectorCopy(vorg, r_refdef.pvsorigin);
|
|
|
|
|
|
|
|
/*rotate it a bit*/
|
|
|
|
RotatePointAroundVector(vaxis[1], vaxis[0], view->axis[1], sin(realtime)*4);
|
|
|
|
CrossProduct(vaxis[0], vaxis[1], vaxis[2]);
|
|
|
|
|
|
|
|
TransformCoord(oldrefdef.vieworg, paxis, porigin, vaxis, vorg, r_refdef.vieworg);
|
|
|
|
TransformDir(vpn, paxis, vaxis, vpn);
|
|
|
|
TransformDir(vright, paxis, vaxis, vright);
|
|
|
|
TransformDir(vup, paxis, vaxis, vup);
|
|
|
|
}
|
|
|
|
Matrix4_ModelViewMatrixFromAxis(r_refdef.m_view, vpn, vright, vup, r_refdef.vieworg);
|
|
|
|
VectorAngles(vpn, vup, r_refdef.viewangles);
|
|
|
|
VectorCopy(r_refdef.vieworg, r_origin);
|
|
|
|
|
|
|
|
/*FIXME: the batch stuff should be done in renderscene*/
|
|
|
|
|
|
|
|
/*fixup the first mesh index*/
|
|
|
|
for (batch = cl.worldmodel->batches; batch; batch = batch->next)
|
|
|
|
{
|
|
|
|
batch->firstmesh = batch->meshes;
|
|
|
|
}
|
|
|
|
|
|
|
|
GL_CullFace(0);
|
|
|
|
|
|
|
|
/*FIXME: can we get away with stenciling the screen?*/
|
|
|
|
/*Add to frustum culling instead of clip planes?*/
|
|
|
|
glplane[0] = -plane.normal[0];
|
|
|
|
glplane[1] = -plane.normal[1];
|
|
|
|
glplane[2] = -plane.normal[2];
|
|
|
|
glplane[3] = plane.dist;
|
|
|
|
qglClipPlane(GL_CLIP_PLANE0, glplane);
|
|
|
|
qglEnable(GL_CLIP_PLANE0);
|
|
|
|
R_RenderScene();
|
|
|
|
qglDisable(GL_CLIP_PLANE0);
|
|
|
|
|
|
|
|
for (batch = cl.worldmodel->batches; batch; batch = batch->next)
|
|
|
|
{
|
|
|
|
batch->firstmesh = 0;
|
|
|
|
}
|
|
|
|
r_refdef = oldrefdef;
|
|
|
|
|
|
|
|
/*broken stuff*/
|
|
|
|
AngleVectors (r_refdef.viewangles, vpn, vright, vup);
|
|
|
|
VectorCopy (r_refdef.vieworg, r_origin);
|
|
|
|
R_SetFrustum (r_refdef.m_projection, r_refdef.m_view);
|
|
|
|
|
|
|
|
/*put GL back the way it was*/
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglLoadMatrixf(r_refdef.m_projection);
|
|
|
|
|
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglLoadMatrixf(r_refdef.m_view);
|
|
|
|
|
|
|
|
GL_CullFace(0);
|
|
|
|
|
|
|
|
#pragma message("warning: there's a bug with rtlights in portals, culling is broken or something. May also be loading the wrong matrix")
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============
|
|
|
|
R_Clear
|
|
|
|
=============
|
|
|
|
*/
|
2005-04-26 16:04:12 +00:00
|
|
|
int gldepthfunc = GL_LEQUAL;
|
2004-08-22 22:29:09 +00:00
|
|
|
void R_Clear (void)
|
|
|
|
{
|
2010-03-14 14:35:56 +00:00
|
|
|
/*tbh, this entire function should be in the backend*/
|
|
|
|
GL_ForceDepthWritable();
|
2004-08-22 22:29:09 +00:00
|
|
|
#ifdef SIDEVIEWS
|
2010-07-11 02:22:39 +00:00
|
|
|
if (gl_ztrick.value && !gl_ztrickdisabled)
|
2004-08-22 22:29:09 +00:00
|
|
|
#else
|
2010-07-11 02:22:39 +00:00
|
|
|
if (gl_ztrick.value)
|
2004-08-22 22:29:09 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
static int trickframe;
|
|
|
|
|
2005-08-07 18:08:13 +00:00
|
|
|
if (gl_clear.value && !(r_refdef.flags & Q2RDF_NOWORLDMODEL))
|
2005-01-07 03:03:56 +00:00
|
|
|
qglClear (GL_COLOR_BUFFER_BIT);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
trickframe++;
|
|
|
|
if (trickframe & 1)
|
|
|
|
{
|
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 0.49999;
|
2005-04-26 16:04:12 +00:00
|
|
|
gldepthfunc=GL_LEQUAL;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gldepthmin = 1;
|
|
|
|
gldepthmax = 0.5;
|
2005-04-26 16:04:12 +00:00
|
|
|
gldepthfunc=GL_GEQUAL;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-07 18:08:13 +00:00
|
|
|
if (gl_clear.value && !r_secondaryview && !(r_refdef.flags & Q2RDF_NOWORLDMODEL))
|
2005-01-07 03:03:56 +00:00
|
|
|
qglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
2004-08-22 22:29:09 +00:00
|
|
|
else
|
2005-01-07 03:03:56 +00:00
|
|
|
qglClear (GL_DEPTH_BUFFER_BIT);
|
2004-08-22 22:29:09 +00:00
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 1;
|
2005-04-26 16:04:12 +00:00
|
|
|
gldepthfunc=GL_LEQUAL;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2005-01-07 03:03:56 +00:00
|
|
|
qglDepthRange (gldepthmin, gldepthmax);
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
2006-06-02 17:42:36 +00:00
|
|
|
#if 0
|
|
|
|
void GLR_SetupFog (void)
|
|
|
|
{
|
|
|
|
if (r_viewleaf)// && r_viewleaf->contents != CONTENTS_EMPTY)
|
|
|
|
{
|
|
|
|
// static fogcolour;
|
|
|
|
float fogcol[4]={0};
|
|
|
|
float fogperc;
|
|
|
|
float fogdist;
|
|
|
|
|
|
|
|
fogperc=0;
|
|
|
|
fogdist=512;
|
|
|
|
switch(r_viewleaf->contents)
|
|
|
|
{
|
|
|
|
case FTECONTENTS_WATER:
|
|
|
|
fogcol[0] = 64/255.0;
|
|
|
|
fogcol[1] = 128/255.0;
|
|
|
|
fogcol[2] = 192/255.0;
|
|
|
|
fogperc=0.2;
|
|
|
|
fogdist=512;
|
|
|
|
break;
|
|
|
|
case FTECONTENTS_SLIME:
|
|
|
|
fogcol[0] = 32/255.0;
|
|
|
|
fogcol[1] = 192/255.0;
|
|
|
|
fogcol[2] = 92/255.0;
|
|
|
|
fogperc=1;
|
|
|
|
fogdist=256;
|
|
|
|
break;
|
|
|
|
case FTECONTENTS_LAVA:
|
|
|
|
fogcol[0] = 192/255.0;
|
|
|
|
fogcol[1] = 32/255.0;
|
|
|
|
fogcol[2] = 64/255.0;
|
|
|
|
fogperc=1;
|
|
|
|
fogdist=128;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fogcol[0] = 192/255.0;
|
|
|
|
fogcol[1] = 192/255.0;
|
|
|
|
fogcol[2] = 192/255.0;
|
|
|
|
fogperc=1;
|
|
|
|
fogdist=1024;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (fogperc)
|
|
|
|
{
|
|
|
|
qglFogi(GL_FOG_MODE, GL_LINEAR);
|
|
|
|
qglFogfv(GL_FOG_COLOR, fogcol);
|
|
|
|
qglFogf(GL_FOG_DENSITY, fogperc);
|
|
|
|
qglFogf(GL_FOG_START, 1);
|
|
|
|
qglFogf(GL_FOG_END, fogdist);
|
|
|
|
qglEnable(GL_FOG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
static void R_RenderMotionBlur(void)
|
|
|
|
{
|
|
|
|
int vwidth = 1, vheight = 1;
|
|
|
|
float vs, vt, cs, ct;
|
2010-03-14 14:35:56 +00:00
|
|
|
#pragma message("backend fixme")
|
|
|
|
Con_Printf("motionblur is not updated for the backend\n");
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
if (gl_config.arb_texture_non_power_of_two)
|
|
|
|
{ //we can use any size, supposedly
|
2009-11-04 21:16:50 +00:00
|
|
|
vwidth = vid.pixelwidth;
|
|
|
|
vheight = vid.pixelheight;
|
2009-07-19 18:13:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //limit the texture size to square and use padding.
|
2009-11-04 21:16:50 +00:00
|
|
|
while (vwidth < vid.pixelwidth)
|
2009-07-19 18:13:03 +00:00
|
|
|
vwidth *= 2;
|
2009-11-04 21:16:50 +00:00
|
|
|
while (vheight < vid.pixelheight)
|
2009-07-19 18:13:03 +00:00
|
|
|
vheight *= 2;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qglViewport (0, 0, vid.pixelwidth, vid.pixelheight);
|
|
|
|
|
|
|
|
PPL_RevertToKnownState();
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
GL_Bind(sceneblur_texture);
|
|
|
|
|
|
|
|
// go 2d
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglPushMatrix();
|
|
|
|
qglLoadIdentity ();
|
2009-11-04 21:16:50 +00:00
|
|
|
qglOrtho (0, vid.pixelwidth, 0, vid.pixelheight, -99999, 99999);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglPushMatrix();
|
|
|
|
qglLoadIdentity ();
|
|
|
|
|
|
|
|
//blend the last frame onto the scene
|
|
|
|
//the maths is because our texture is over-sized (must be power of two)
|
2009-11-04 21:16:50 +00:00
|
|
|
cs = vs = (float)vid.pixelwidth / vwidth * 0.5;
|
|
|
|
ct = vt = (float)vid.pixelheight / vheight * 0.5;
|
2009-07-19 18:13:03 +00:00
|
|
|
vs *= gl_motionblurscale.value;
|
|
|
|
vt *= gl_motionblurscale.value;
|
|
|
|
|
|
|
|
qglDisable (GL_DEPTH_TEST);
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_CullFace(0);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglDisable (GL_ALPHA_TEST);
|
|
|
|
qglEnable(GL_BLEND);
|
|
|
|
qglColor4f(1, 1, 1, gl_motionblur.value);
|
|
|
|
qglBegin(GL_QUADS);
|
|
|
|
qglTexCoord2f(cs-vs, ct-vt);
|
|
|
|
qglVertex2f(0, 0);
|
|
|
|
qglTexCoord2f(cs+vs, ct-vt);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(vid.pixelwidth, 0);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglTexCoord2f(cs+vs, ct+vt);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(vid.pixelwidth, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglTexCoord2f(cs-vs, ct+vt);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(0, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglEnd();
|
|
|
|
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglPopMatrix();
|
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglPopMatrix();
|
|
|
|
|
|
|
|
|
|
|
|
//copy the image into the texture so that we can play with it next frame too!
|
2009-11-04 21:16:50 +00:00
|
|
|
qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, vwidth, vheight, 0);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
|
|
|
|
PPL_RevertToKnownState();
|
2009-07-19 18:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void R_RenderWaterWarp(void)
|
|
|
|
{
|
|
|
|
float vwidth = 1, vheight = 1;
|
|
|
|
float vs, vt;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
PPL_RevertToKnownState();
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
#pragma message("backend fixme")
|
|
|
|
Con_Printf("waterwarp is not updated for the backend\n");
|
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
// get the powers of 2 for the size of the texture that will hold the scene
|
|
|
|
|
|
|
|
if (gl_config.arb_texture_non_power_of_two)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
vwidth = vid.pixelwidth;
|
|
|
|
vheight = vid.pixelheight;
|
2009-07-19 18:13:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
while (vwidth < vid.pixelwidth)
|
2009-07-19 18:13:03 +00:00
|
|
|
{
|
|
|
|
vwidth *= 2;
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
while (vheight < vid.pixelheight)
|
2009-07-19 18:13:03 +00:00
|
|
|
{
|
|
|
|
vheight *= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the maxtexcoords while we're at it
|
2009-11-04 21:16:50 +00:00
|
|
|
vs = vid.pixelwidth / vwidth;
|
|
|
|
vt = vid.pixelheight / vheight;
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
// 2d mode, but upside down to quake's normal 2d drawing
|
|
|
|
// this makes grabbing the sreen a lot easier
|
2009-11-04 21:16:50 +00:00
|
|
|
qglViewport (0, 0, vid.pixelwidth, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
// Push the matrices to go into 2d mode, that matches opengl's mode
|
|
|
|
qglPushMatrix();
|
|
|
|
qglLoadIdentity ();
|
|
|
|
// TODO: use actual window width and height
|
2009-11-04 21:16:50 +00:00
|
|
|
qglOrtho (0, vid.pixelwidth, 0, vid.pixelheight, -99999, 99999);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglPushMatrix();
|
|
|
|
qglLoadIdentity ();
|
|
|
|
|
|
|
|
qglDisable (GL_DEPTH_TEST);
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_CullFace(0);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglDisable (GL_BLEND);
|
|
|
|
qglEnable (GL_ALPHA_TEST);
|
|
|
|
|
|
|
|
// copy the scene to texture
|
|
|
|
GL_Bind(scenepp_texture);
|
2009-11-07 13:29:15 +00:00
|
|
|
qglEnable(GL_TEXTURE_2D);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, vwidth, vheight, 0);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf(CON_ERROR "GL Error after qglCopyTexImage2D\n");
|
|
|
|
|
|
|
|
// Here we apply the shaders - currently just waterwarp
|
|
|
|
GLSlang_UseProgram(scenepp_ww_program);
|
|
|
|
//keep the amp proportional to the size of the scene in texture coords
|
|
|
|
// WARNING - waterwarp can change the amplitude, but if it's too big it'll exceed
|
|
|
|
// the size determined by the edge texture, after which black bits will be shown.
|
|
|
|
// Suggest clamping to a suitable range.
|
|
|
|
if (r_waterwarp.value<0)
|
|
|
|
{
|
|
|
|
GLSlang_SetUniform1f(scenepp_ww_parm_ampscalef, (0.005 / 0.625) * vs*(-r_waterwarp.value));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GLSlang_SetUniform1f(scenepp_ww_parm_ampscalef, (0.005 / 0.625) * vs*r_waterwarp.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("GL Error after GLSlang_UseProgram\n");
|
|
|
|
|
|
|
|
{
|
|
|
|
float xmin, xmax, ymin, ymax;
|
|
|
|
|
|
|
|
xmin = cl.time * 0.25;
|
|
|
|
ymin = cl.time * 0.25;
|
|
|
|
xmax = xmin + 1;
|
|
|
|
ymax = ymin + 1/vt*vs;
|
|
|
|
|
2009-11-07 13:29:15 +00:00
|
|
|
GL_SelectTexture(1);
|
|
|
|
qglEnable(GL_TEXTURE_2D);
|
2009-07-19 18:13:03 +00:00
|
|
|
GL_Bind (scenepp_texture_warp);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_SelectTexture(2);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglEnable(GL_TEXTURE_2D);
|
|
|
|
GL_Bind(scenepp_texture_edge);
|
|
|
|
|
|
|
|
qglBegin(GL_QUADS);
|
|
|
|
|
|
|
|
qglMTexCoord2fSGIS (mtexid0, 0, 0);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1, xmin, ymin);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1+1, 0, 0);
|
|
|
|
qglVertex2f(0, 0);
|
|
|
|
|
|
|
|
qglMTexCoord2fSGIS (mtexid0, vs, 0);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1, xmax, ymin);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1+1, 1, 0);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(vid.pixelwidth, 0);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
qglMTexCoord2fSGIS (mtexid0, vs, vt);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1, xmax, ymax);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1+1, 1, 1);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(vid.pixelwidth, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
qglMTexCoord2fSGIS (mtexid0, 0, vt);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1, xmin, ymax);
|
|
|
|
qglMTexCoord2fSGIS (mtexid1+1, 0, 1);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(0, vid.pixelheight);
|
2009-07-20 02:50:00 +00:00
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
qglEnd();
|
|
|
|
|
|
|
|
qglDisable(GL_TEXTURE_2D);
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_SelectTexture(1);
|
2009-11-07 13:29:15 +00:00
|
|
|
qglDisable(GL_TEXTURE_2D);
|
|
|
|
GL_SelectTexture(0);
|
2009-07-19 18:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disable shaders
|
|
|
|
GLSlang_UseProgram(0);
|
|
|
|
|
|
|
|
// After all the post processing, pop the matrices
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglPopMatrix();
|
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglPopMatrix();
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
PPL_RevertToKnownState();
|
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("GL Error after drawing with shaderobjects\n");
|
|
|
|
}
|
|
|
|
|
2009-07-20 07:45:05 +00:00
|
|
|
#ifdef FISH
|
2010-05-01 22:47:47 +00:00
|
|
|
/*FIXME: we could use geometry shaders to draw to all 6 faces at once*/
|
2009-07-19 18:13:03 +00:00
|
|
|
qboolean R_RenderScene_Fish(void)
|
|
|
|
{
|
|
|
|
int cmapsize = 512;
|
|
|
|
int i;
|
|
|
|
static vec3_t ang[6] =
|
|
|
|
{ {0, -90, 0}, {0, 90, 0},
|
|
|
|
{90, 0, 0}, {-90, 0, 0},
|
|
|
|
{0, 0, 0}, {0, -180, 0} };
|
|
|
|
int order[6] = {4, 0, 1, 5, 3, 2};
|
|
|
|
int numsides = 4;
|
|
|
|
vec3_t saveang;
|
|
|
|
int rot45 = 0;
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
#pragma message("backend fixme")
|
|
|
|
Con_Printf("fisheye/panorama is not updated for the backend\n");
|
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
if (!scenepp_panorama_program)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (gl_config.arb_texture_non_power_of_two)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if (vid.pixelwidth < vid.pixelheight)
|
|
|
|
cmapsize = vid.pixelwidth;
|
2009-07-19 18:13:03 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
cmapsize = vid.pixelheight;
|
2009-07-19 18:13:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
while (cmapsize > vid.pixelwidth || cmapsize > vid.pixelheight)
|
2009-07-19 18:13:03 +00:00
|
|
|
{
|
|
|
|
cmapsize /= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorCopy(r_refdef.viewangles, saveang);
|
|
|
|
saveang[2] = 0;
|
|
|
|
|
|
|
|
if (ffov.value < 0)
|
|
|
|
{
|
|
|
|
//panoramic view needs at most the four sides
|
|
|
|
if (ffov.value >= -90)
|
|
|
|
numsides = 1;
|
|
|
|
// else if (ffov.value >= -180)
|
|
|
|
// {
|
|
|
|
// numsides = 2;
|
|
|
|
// rot45 = 1;
|
|
|
|
// }
|
|
|
|
else if (ffov.value >= -270)
|
|
|
|
numsides = 3;
|
|
|
|
else
|
|
|
|
numsides = 4;
|
|
|
|
|
|
|
|
order[0] = 4;
|
|
|
|
order[1] = 0;
|
|
|
|
order[2] = 1;
|
|
|
|
order[3] = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//fisheye view sees a full sphere
|
|
|
|
//
|
|
|
|
if (ffov.value <= 77)
|
|
|
|
numsides = 1;
|
|
|
|
// else if (ffov.value <= 180)
|
|
|
|
// {
|
|
|
|
// numsides = 3;
|
|
|
|
// rot45 = 3;
|
|
|
|
// }
|
|
|
|
else if (ffov.value <= 270)
|
|
|
|
numsides = 5;
|
|
|
|
else
|
|
|
|
numsides = 6;
|
|
|
|
|
|
|
|
order[0] = 4;
|
|
|
|
order[1] = 0;
|
|
|
|
order[2] = 3;
|
|
|
|
order[3] = 1;
|
|
|
|
order[4] = 2;
|
|
|
|
order[5] = 5;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qglViewport (0, vid.pixelheight - cmapsize, cmapsize, cmapsize);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!TEXVALID(scenepp_fisheye_texture))
|
2009-07-19 18:13:03 +00:00
|
|
|
{
|
|
|
|
scenepp_fisheye_texture = GL_AllocNewTexture();
|
|
|
|
|
|
|
|
qglDisable(GL_TEXTURE_2D);
|
|
|
|
qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_BindType(GL_TEXTURE_CUBE_MAP_ARB, scenepp_fisheye_texture);
|
2009-07-19 18:13:03 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
qglCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + i, 0, GL_RGB, 0, 0, cmapsize, cmapsize, 0);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
|
|
|
|
qglEnable(GL_TEXTURE_2D);
|
|
|
|
qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
r_refdef.vrect.width = (cmapsize+0.99)*vid.width/vid.pixelwidth;
|
|
|
|
r_refdef.vrect.height = (cmapsize+0.99)*vid.height/vid.pixelheight;
|
2009-07-19 18:13:03 +00:00
|
|
|
r_refdef.vrect.x = 0;
|
|
|
|
r_refdef.vrect.y = vid.height - r_refdef.vrect.height;
|
|
|
|
|
|
|
|
ang[0][0] = -saveang[0];
|
|
|
|
ang[0][1] = -90;
|
|
|
|
ang[0][2] = -saveang[0];
|
|
|
|
|
|
|
|
ang[1][0] = -saveang[0];
|
|
|
|
ang[1][1] = 90;
|
|
|
|
ang[1][2] = saveang[0];
|
|
|
|
ang[5][0] = -saveang[0]*2;
|
|
|
|
for (i = 0; i < numsides; i++)
|
|
|
|
{
|
|
|
|
r_refdef.fov_x = 90;
|
|
|
|
r_refdef.fov_y = 90;
|
|
|
|
r_refdef.viewangles[0] = saveang[0]+ang[order[i]][0];
|
|
|
|
r_refdef.viewangles[1] = saveang[1]+ang[order[i]][1];
|
|
|
|
r_refdef.viewangles[2] = saveang[2]+ang[order[i]][2];
|
|
|
|
|
|
|
|
R_Clear ();
|
|
|
|
|
|
|
|
// GLR_SetupFog ();
|
|
|
|
|
|
|
|
GL_SetShaderState2D(false);
|
|
|
|
|
|
|
|
// render normal view
|
2009-07-20 02:50:00 +00:00
|
|
|
R_RenderScene ();
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
qglDisable(GL_TEXTURE_2D);
|
|
|
|
qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
GL_BindType(GL_TEXTURE_CUBE_MAP_ARB, scenepp_fisheye_texture);
|
|
|
|
qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + order[i], 0, 0, 0, 0, 0, cmapsize, cmapsize);
|
|
|
|
qglEnable(GL_TEXTURE_2D);
|
|
|
|
qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
}
|
|
|
|
|
|
|
|
//qglClear (GL_COLOR_BUFFER_BIT);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglViewport (0, 0, vid.pixelwidth, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
|
|
|
|
qglDisable(GL_TEXTURE_2D);
|
|
|
|
GL_BindType(GL_TEXTURE_CUBE_MAP_ARB, scenepp_fisheye_texture);
|
|
|
|
qglEnable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
|
|
|
|
if (scenepp_panorama_program && ffov.value < 0)
|
|
|
|
{
|
|
|
|
GLSlang_UseProgram(scenepp_panorama_program);
|
|
|
|
GLSlang_SetUniform1f(scenepp_panorama_parm_fov, -ffov.value*3.1415926535897932384626433832795/180);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GLSlang_UseProgram(scenepp_fisheye_program);
|
|
|
|
GLSlang_SetUniform1f(scenepp_fisheye_parm_fov, ffov.value*3.1415926535897932384626433832795/180);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// go 2d
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglPushMatrix();
|
|
|
|
qglLoadIdentity ();
|
2009-11-04 21:16:50 +00:00
|
|
|
qglOrtho (0, vid.pixelwidth, 0, vid.pixelheight, -99999, 99999);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglPushMatrix();
|
|
|
|
qglLoadIdentity ();
|
|
|
|
|
|
|
|
qglDisable (GL_DEPTH_TEST);
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_CullFace(0);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglDisable (GL_ALPHA_TEST);
|
|
|
|
qglDisable(GL_BLEND);
|
|
|
|
qglBegin(GL_QUADS);
|
|
|
|
qglTexCoord2f(-0.5, -0.5);
|
|
|
|
qglVertex2f(0, 0);
|
|
|
|
qglTexCoord2f(0.5, -0.5);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(vid.pixelwidth, 0);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglTexCoord2f(0.5, 0.5);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(vid.pixelwidth, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglTexCoord2f(-0.5, 0.5);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglVertex2f(0, vid.pixelheight);
|
2009-07-19 18:13:03 +00:00
|
|
|
qglEnd();
|
|
|
|
|
|
|
|
qglMatrixMode(GL_PROJECTION);
|
|
|
|
qglPopMatrix();
|
|
|
|
qglMatrixMode(GL_MODELVIEW);
|
|
|
|
qglPopMatrix();
|
|
|
|
|
|
|
|
qglDisable(GL_TEXTURE_CUBE_MAP_ARB);
|
|
|
|
qglEnable(GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
GLSlang_UseProgram(0);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-07-20 07:45:05 +00:00
|
|
|
#endif
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
R_RenderView
|
|
|
|
|
|
|
|
r_refdef must be set before the first call
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void GLR_RenderView (void)
|
|
|
|
{
|
|
|
|
double time1 = 0, time2;
|
|
|
|
|
2005-04-26 16:04:12 +00:00
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("GL Error before drawing scene\n");
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (r_norefresh.value || !vid.pixelwidth || !vid.pixelheight)
|
2005-01-17 17:44:54 +00:00
|
|
|
{
|
|
|
|
GL_DoSwap();
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
2005-01-17 17:44:54 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-08-07 18:08:13 +00:00
|
|
|
if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL))
|
2004-08-22 22:29:09 +00:00
|
|
|
if (!r_worldentity.model || !cl.worldmodel)
|
2005-01-17 17:44:54 +00:00
|
|
|
{
|
|
|
|
GL_DoSwap();
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
2005-01-17 17:44:54 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
// Sys_Error ("R_RenderView: NULL worldmodel");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (qglPNTrianglesiATI)
|
|
|
|
{
|
2010-02-06 01:25:04 +00:00
|
|
|
if (gl_ati_truform_type.ival)
|
2004-08-22 22:29:09 +00:00
|
|
|
{ //linear
|
|
|
|
qglPNTrianglesiATI(GL_PN_TRIANGLES_NORMAL_MODE_ATI, GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI);
|
|
|
|
qglPNTrianglesiATI(GL_PN_TRIANGLES_POINT_MODE_ATI, GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //quadric
|
|
|
|
qglPNTrianglesiATI(GL_PN_TRIANGLES_NORMAL_MODE_ATI, GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI);
|
|
|
|
qglPNTrianglesiATI(GL_PN_TRIANGLES_POINT_MODE_ATI, GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI);
|
|
|
|
}
|
|
|
|
qglPNTrianglesfATI(GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI, gl_ati_truform_tesselation.value);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (gl_finish.ival)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedMark();
|
2005-01-07 03:03:56 +00:00
|
|
|
qglFinish ();
|
2004-12-15 19:53:30 +00:00
|
|
|
RSpeedEnd(RSPEED_FINISH);
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (r_speeds.ival)
|
2004-12-15 19:53:30 +00:00
|
|
|
{
|
2004-08-22 22:29:09 +00:00
|
|
|
time1 = Sys_DoubleTime ();
|
|
|
|
c_brush_polys = 0;
|
|
|
|
c_alias_polys = 0;
|
|
|
|
}
|
|
|
|
|
2009-07-20 02:50:00 +00:00
|
|
|
#ifdef FISH
|
2009-07-19 18:13:03 +00:00
|
|
|
if (ffov.value && cls.allow_fish && !(r_refdef.flags & Q2RDF_NOWORLDMODEL) && R_RenderScene_Fish())
|
|
|
|
{
|
|
|
|
//fisheye does its own rendering.
|
|
|
|
}
|
|
|
|
else
|
2009-07-20 02:50:00 +00:00
|
|
|
#endif
|
2009-07-20 07:45:05 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
GL_SetShaderState2D(false);
|
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
R_Clear ();
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
// GLR_SetupFog ();
|
2006-06-02 17:42:36 +00:00
|
|
|
|
2009-07-19 18:13:03 +00:00
|
|
|
// render normal view
|
2009-07-20 02:50:00 +00:00
|
|
|
R_RenderScene ();
|
2009-07-19 18:13:03 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (r_bloom.ival)
|
|
|
|
R_BloomBlend();
|
2006-03-03 03:31:19 +00:00
|
|
|
|
2006-06-02 17:42:36 +00:00
|
|
|
// qglDisable(GL_FOG);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (r_speeds.ival)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
// glFinish ();
|
|
|
|
time2 = Sys_DoubleTime ();
|
2004-12-15 19:53:30 +00:00
|
|
|
|
|
|
|
RQuantAdd(RQUANT_MSECS, (int)((time2-time1)*1000000));
|
|
|
|
|
|
|
|
RQuantAdd(RQUANT_WPOLYS, c_brush_polys);
|
|
|
|
RQuantAdd(RQUANT_EPOLYS, c_alias_polys);
|
2009-07-20 02:50:00 +00:00
|
|
|
// Con_Printf ("%3i ms %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys);
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2005-01-12 22:15:50 +00:00
|
|
|
|
2005-04-26 16:04:12 +00:00
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("GL Error drawing scene\n");
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
if (r_refdef.flags & Q2RDF_NOWORLDMODEL)
|
|
|
|
return;
|
|
|
|
|
2005-01-12 22:15:50 +00:00
|
|
|
// SCENE POST PROCESSING
|
|
|
|
// we check if we need to use any shaders - currently it's just waterwarp
|
2005-09-29 23:32:22 +00:00
|
|
|
if ((r_waterwarp.value>0 && r_viewleaf && r_viewleaf->contents <= Q1CONTENTS_WATER))
|
2010-07-11 02:22:39 +00:00
|
|
|
{
|
|
|
|
GL_Set2D();
|
|
|
|
if (scenepp_waterwarp)
|
|
|
|
R2D_ScalePic(0, 0, vid.width, vid.height, scenepp_waterwarp);
|
|
|
|
else if (scenepp_ww_program)
|
|
|
|
R_RenderWaterWarp();
|
|
|
|
}
|
2005-05-27 08:24:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-06-22 16:38:49 +00:00
|
|
|
if (gl_motionblur.value>0 && gl_motionblur.value < 1 && qglCopyTexImage2D)
|
2009-07-19 18:13:03 +00:00
|
|
|
R_RenderMotionBlur();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2004-12-15 19:53:30 +00:00
|
|
|
|
|
|
|
#endif
|