2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
gl_rmain.c
|
|
|
|
|
2003-05-09 01:41:56 +00:00
|
|
|
(no description)
|
2001-02-19 21:15:25 +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
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2004-05-07 03:54:35 +00:00
|
|
|
#include "QF/draw.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-05-21 00:22:35 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "QF/skin.h"
|
|
|
|
#include "QF/sound.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-14 20:35:32 +00:00
|
|
|
#include "QF/vid.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
|
|
|
|
#include "QF/scene/entity.h"
|
|
|
|
|
2001-06-24 09:25:55 +00:00
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
2022-03-14 05:31:23 +00:00
|
|
|
#include "QF/GL/qf_alias.h"
|
2012-02-22 12:53:17 +00:00
|
|
|
#include "QF/GL/qf_draw.h"
|
2012-05-17 06:58:29 +00:00
|
|
|
#include "QF/GL/qf_iqm.h"
|
2022-03-14 05:31:23 +00:00
|
|
|
#include "QF/GL/qf_particles.h"
|
2001-08-26 17:13:33 +00:00
|
|
|
#include "QF/GL/qf_rlight.h"
|
2003-01-06 18:28:13 +00:00
|
|
|
#include "QF/GL/qf_rmain.h"
|
2001-08-26 17:13:33 +00:00
|
|
|
#include "QF/GL/qf_rsurf.h"
|
2022-03-14 05:31:23 +00:00
|
|
|
#include "QF/GL/qf_sprite.h"
|
2001-06-24 09:25:55 +00:00
|
|
|
#include "QF/GL/qf_vid.h"
|
|
|
|
|
2001-08-02 02:18:04 +00:00
|
|
|
#include "compat.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2003-03-20 19:58:18 +00:00
|
|
|
#include "varrays.h"
|
2022-03-07 17:10:47 +00:00
|
|
|
#include "vid_gl.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
float gl_r_world_matrix[16];
|
2021-03-19 11:18:45 +00:00
|
|
|
//FIXME static float r_base_world_matrix[16];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-02-17 09:33:07 +00:00
|
|
|
//vec3_t gl_shadecolor; // Ender (Extend) Colormod
|
|
|
|
float gl_modelalpha; // Ender (Extend) Alpha
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
void
|
2001-05-14 06:47:38 +00:00
|
|
|
glrmain_init (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-10-02 00:01:05 +00:00
|
|
|
gldepthmin = 0;
|
|
|
|
gldepthmax = 1;
|
|
|
|
qfglDepthFunc (GL_LEQUAL);
|
|
|
|
qfglDepthRange (gldepthmin, gldepthmax);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
|
|
|
|
gl_overbright_f (0, 0);
|
|
|
|
gl_multitexture_f (0, 0);
|
2001-05-14 06:47:38 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2007-03-22 23:20:57 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
gl_R_RotateForEntity (entity_t *e)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-09 14:52:40 +00:00
|
|
|
mat4f_t mat;
|
|
|
|
Transform_GetWorldMatrix (e->transform, mat);
|
2022-03-30 15:07:20 +00:00
|
|
|
qfglMultMatrixf ((vec_t*)&mat[0]);//FIXME
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2003-05-08 22:16:30 +00:00
|
|
|
|
2022-03-17 08:50:38 +00:00
|
|
|
void
|
|
|
|
gl_R_RenderEntities (entqueue_t *queue)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!r_drawentities)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// LordHavoc: split into 3 loops to simplify state changes
|
|
|
|
|
2004-03-15 21:32:19 +00:00
|
|
|
if (gl_mtex_active_tmus >= 2) {
|
|
|
|
qglActiveTexture (gl_mtex_enum + 1);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
|
|
|
qfglDisable (GL_TEXTURE_2D);
|
|
|
|
qglActiveTexture (gl_mtex_enum + 0);
|
|
|
|
}
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_affinemodels)
|
2001-12-19 18:32:26 +00:00
|
|
|
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
2012-02-22 02:09:09 +00:00
|
|
|
if (gl_tess)
|
2004-01-26 00:13:47 +00:00
|
|
|
qfglEnable (GL_PN_TRIANGLES_ATI);
|
2004-03-10 08:14:38 +00:00
|
|
|
qfglEnable (GL_CULL_FACE);
|
2012-05-21 23:23:22 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_vector_light) {
|
2004-05-02 21:21:00 +00:00
|
|
|
qfglEnable (GL_LIGHTING);
|
|
|
|
qfglEnable (GL_NORMALIZE);
|
2012-02-22 02:09:09 +00:00
|
|
|
} else if (gl_tess) {
|
2004-05-02 21:21:00 +00:00
|
|
|
qfglEnable (GL_NORMALIZE);
|
|
|
|
}
|
2012-05-17 06:58:29 +00:00
|
|
|
|
2022-03-17 08:50:38 +00:00
|
|
|
for (size_t i = 0; i < queue->ent_queues[mod_alias].size; i++) { \
|
|
|
|
entity_t *ent = queue->ent_queues[mod_alias].a[i]; \
|
2021-07-22 06:39:28 +00:00
|
|
|
gl_R_DrawAliasModel (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2004-02-21 05:36:19 +00:00
|
|
|
qfglColor3ubv (color_white);
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2004-03-15 21:32:19 +00:00
|
|
|
qfglDisable (GL_NORMALIZE);
|
|
|
|
qfglDisable (GL_LIGHTING);
|
2004-05-02 21:21:00 +00:00
|
|
|
|
2012-02-22 02:09:09 +00:00
|
|
|
if (gl_tess)
|
2004-01-26 00:13:47 +00:00
|
|
|
qfglDisable (GL_PN_TRIANGLES_ATI);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_affinemodels)
|
2001-12-19 18:32:26 +00:00
|
|
|
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
2004-02-24 20:50:55 +00:00
|
|
|
if (gl_mtex_active_tmus >= 2) { // FIXME: Ugly, but faster than cleaning
|
|
|
|
// up in every R_DrawAliasModel()!
|
2004-02-21 05:36:19 +00:00
|
|
|
qglActiveTexture (gl_mtex_enum + 1);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_combine_capable && gl_overbright) {
|
2004-03-07 23:51:29 +00:00
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
2012-02-22 02:09:09 +00:00
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, gl_rgb_scale);
|
2004-02-21 05:36:19 +00:00
|
|
|
} else {
|
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
}
|
|
|
|
qfglDisable (GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
qglActiveTexture (gl_mtex_enum + 0);
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-17 08:50:38 +00:00
|
|
|
for (size_t i = 0; i < queue->ent_queues[mod_iqm].size; i++) { \
|
|
|
|
entity_t *ent = queue->ent_queues[mod_iqm].a[i]; \
|
2021-07-22 06:39:28 +00:00
|
|
|
gl_R_DrawIQMModel (ent);
|
2012-05-17 06:58:29 +00:00
|
|
|
}
|
|
|
|
qfglColor3ubv (color_white);
|
|
|
|
|
|
|
|
qfglDisable (GL_CULL_FACE);
|
2001-10-02 01:48:51 +00:00
|
|
|
qfglEnable (GL_ALPHA_TEST);
|
2003-03-20 19:58:18 +00:00
|
|
|
if (gl_va_capable)
|
2012-02-17 09:33:07 +00:00
|
|
|
qfglInterleavedArrays (GL_T2F_C4UB_V3F, 0, gl_spriteVertexArray);
|
2022-03-17 08:50:38 +00:00
|
|
|
for (size_t i = 0; i < queue->ent_queues[mod_sprite].size; i++) { \
|
|
|
|
entity_t *ent = queue->ent_queues[mod_sprite].a[i]; \
|
2022-03-14 05:31:23 +00:00
|
|
|
gl_R_DrawSpriteModel (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-10-02 01:48:51 +00:00
|
|
|
qfglDisable (GL_ALPHA_TEST);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
static void
|
|
|
|
R_DrawViewModel (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-07-22 06:39:28 +00:00
|
|
|
entity_t *ent = vr_data.view_model;
|
2012-02-14 08:28:09 +00:00
|
|
|
if (vr_data.inhibit_viewmodel
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
|| !r_drawviewmodel
|
|
|
|
|| !r_drawentities
|
2021-07-22 06:39:28 +00:00
|
|
|
|| !ent->renderer.model)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2004-04-28 04:07:50 +00:00
|
|
|
// hack the depth range to prevent view model from poking into walls
|
|
|
|
qfglDepthRange (gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));
|
|
|
|
qfglEnable (GL_CULL_FACE);
|
2004-05-02 21:21:00 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_vector_light) {
|
2004-05-02 21:21:00 +00:00
|
|
|
qfglEnable (GL_LIGHTING);
|
|
|
|
qfglEnable (GL_NORMALIZE);
|
2012-02-22 02:09:09 +00:00
|
|
|
} else if (gl_tess) {
|
2004-05-02 21:21:00 +00:00
|
|
|
qfglEnable (GL_NORMALIZE);
|
|
|
|
}
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_affinemodels)
|
2001-12-19 20:15:38 +00:00
|
|
|
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
2004-03-15 21:32:19 +00:00
|
|
|
if (gl_mtex_active_tmus >= 2) {
|
|
|
|
qglActiveTexture (gl_mtex_enum + 1);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
|
|
|
qfglDisable (GL_TEXTURE_2D);
|
|
|
|
qglActiveTexture (gl_mtex_enum + 0);
|
|
|
|
}
|
2004-02-21 05:36:19 +00:00
|
|
|
|
2021-07-22 06:39:28 +00:00
|
|
|
gl_R_DrawAliasModel (ent);
|
2004-03-15 21:32:19 +00:00
|
|
|
|
2004-02-21 05:36:19 +00:00
|
|
|
qfglColor3ubv (color_white);
|
2004-02-27 21:42:52 +00:00
|
|
|
if (gl_mtex_active_tmus >= 2) { // FIXME: Ugly, but faster than cleaning
|
|
|
|
// up in every R_DrawAliasModel()!
|
2004-02-21 05:36:19 +00:00
|
|
|
qglActiveTexture (gl_mtex_enum + 1);
|
|
|
|
qfglEnable (GL_TEXTURE_2D);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_combine_capable && gl_overbright) {
|
2004-03-07 23:51:29 +00:00
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
|
2012-02-22 02:09:09 +00:00
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_RGB_SCALE, gl_rgb_scale);
|
2004-02-21 05:36:19 +00:00
|
|
|
} else {
|
|
|
|
qfglTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
|
|
}
|
|
|
|
qfglDisable (GL_TEXTURE_2D);
|
|
|
|
|
|
|
|
qglActiveTexture (gl_mtex_enum + 0);
|
|
|
|
}
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_affinemodels)
|
2001-12-19 20:15:38 +00:00
|
|
|
qfglHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE);
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2004-03-15 21:32:19 +00:00
|
|
|
qfglDisable (GL_NORMALIZE);
|
|
|
|
qfglDisable (GL_LIGHTING);
|
2004-05-02 21:21:00 +00:00
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2004-03-10 08:14:38 +00:00
|
|
|
qfglDisable (GL_CULL_FACE);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDepthRange (gldepthmin, gldepthmax);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-15 16:53:34 +00:00
|
|
|
static void
|
|
|
|
R_SetupGL (void)
|
|
|
|
{
|
2022-03-30 05:55:32 +00:00
|
|
|
qfglMatrixMode (GL_PROJECTION);
|
2022-03-30 15:07:20 +00:00
|
|
|
qfglLoadMatrixf ((vec_t*)&gl_ctx->projection[0]);//FIXME
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2022-03-14 15:09:37 +00:00
|
|
|
qfglFrontFace (GL_CW);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglMatrixMode (GL_MODELVIEW);
|
|
|
|
qfglLoadIdentity ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
static mat4f_t z_up = {
|
[gl] Make perspective matrix setup consistent
Now GL perspective matrix setup matches that of GLSL and Vulkan, and
GL's z_up matrix matches GLSL's (as it should, since they're really
going through the same API). GL also needs the depth adjustmet matrix
now. Other than having to google the docs for glFrustum, there's nothing
wrong with the function itself, but it's nice to have direct control
over the matrices.
In the process, I discovered how horribly confused I've been at times
with respect to the handedness of GL and Quake: GL is right-handed
(y-up, z-out, x-right), as is Quake itself (but z-up, y-left, x-in), but
as the perspective matrix used in the three renderers expects z-in,
having x-right and y-up makes the matrix effectively left-handed (not
for Vulkan though, because there it's y-down, x-right, z-up, so
right-handed again).
2022-03-27 04:15:15 +00:00
|
|
|
{ 0, 0, 1, 0},
|
2021-03-19 11:18:45 +00:00
|
|
|
{-1, 0, 0, 0},
|
|
|
|
{ 0, 1, 0, 0},
|
|
|
|
{ 0, 0, 0, 1},
|
|
|
|
};
|
|
|
|
mat4f_t view;
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
mmulf (view, z_up, r_refdef.camera_inverse);
|
2022-03-30 15:07:20 +00:00
|
|
|
qfglLoadMatrixf ((vec_t*)&view[0]);//FIXME
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-22 07:32:34 +00:00
|
|
|
qfglGetFloatv (GL_MODELVIEW_MATRIX, gl_r_world_matrix);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// set drawing parms
|
2004-04-28 04:07:50 +00:00
|
|
|
// qfglEnable (GL_CULL_FACE);
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglDisable (GL_ALPHA_TEST);
|
|
|
|
qfglAlphaFunc (GL_GREATER, 0.5);
|
|
|
|
qfglEnable (GL_DEPTH_TEST);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (gl_dlight_smooth)
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglShadeModel (GL_SMOOTH);
|
2001-05-14 06:47:38 +00:00
|
|
|
else
|
2001-06-26 02:26:46 +00:00
|
|
|
qfglShadeModel (GL_FLAT);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-03-26 03:08:06 +00:00
|
|
|
void
|
|
|
|
gl_R_RenderView (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (r_norefresh) {
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2022-03-14 06:27:43 +00:00
|
|
|
if (!r_refdef.worldmodel) {
|
2021-12-02 09:30:57 +00:00
|
|
|
return;
|
2021-03-09 14:52:40 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-26 03:08:06 +00:00
|
|
|
R_SetupGL ();
|
|
|
|
gl_Fog_EnableGFog ();
|
2003-01-15 16:53:34 +00:00
|
|
|
|
2022-03-26 03:08:06 +00:00
|
|
|
gl_R_DrawWorld ();
|
|
|
|
S_ExtraUpdate (); // don't let sound get messed up if going slow
|
|
|
|
gl_R_RenderDlights ();
|
2022-04-25 22:22:45 +00:00
|
|
|
if (vr_data.view_model) {
|
|
|
|
R_DrawViewModel ();
|
|
|
|
}
|
2003-01-15 16:53:34 +00:00
|
|
|
|
2022-03-26 03:08:06 +00:00
|
|
|
gl_Fog_DisableGFog ();
|
2022-03-14 14:51:30 +00:00
|
|
|
}
|
2011-12-23 03:51:47 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
gl_R_ClearState (void)
|
2011-12-23 03:51:47 +00:00
|
|
|
{
|
2022-03-14 06:27:43 +00:00
|
|
|
r_refdef.worldmodel = 0;
|
2011-12-23 03:51:47 +00:00
|
|
|
R_ClearEfrags ();
|
|
|
|
R_ClearDlights ();
|
2021-12-19 04:08:39 +00:00
|
|
|
R_ClearParticles ();
|
2011-12-23 03:51:47 +00:00
|
|
|
}
|