2012-01-01 14:58:12 +00:00
|
|
|
/*
|
|
|
|
glsl_alias.c
|
|
|
|
|
|
|
|
GLSL Alias model rendering
|
|
|
|
|
|
|
|
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2012/1/1
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2012-01-02 04:15:51 +00:00
|
|
|
#include <stdlib.h>
|
2012-01-01 14:58:12 +00:00
|
|
|
|
2012-04-25 01:09:23 +00:00
|
|
|
#include "QF/cvar.h"
|
2012-01-02 10:15:01 +00:00
|
|
|
#include "QF/render.h"
|
2012-01-22 06:48:32 +00:00
|
|
|
#include "QF/skin.h"
|
2012-04-25 01:09:23 +00:00
|
|
|
#include "QF/sys.h"
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
|
|
|
|
2012-01-01 14:58:12 +00:00
|
|
|
#include "QF/GLSL/defines.h"
|
|
|
|
#include "QF/GLSL/funcs.h"
|
|
|
|
#include "QF/GLSL/qf_alias.h"
|
2012-01-02 04:15:51 +00:00
|
|
|
#include "QF/GLSL/qf_textures.h"
|
2012-01-02 02:18:34 +00:00
|
|
|
#include "QF/GLSL/qf_vid.h"
|
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2012-01-02 04:15:51 +00:00
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
static const char *alias_vert_effects[] =
|
|
|
|
{
|
|
|
|
"QuakeForge.Vertex.mdl",
|
2013-06-07 08:12:44 +00:00
|
|
|
0
|
2013-05-12 04:51:02 +00:00
|
|
|
};
|
2012-01-02 02:18:34 +00:00
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
static const char *alias_frag_effects[] =
|
|
|
|
{
|
|
|
|
"QuakeForge.Fragment.fog",
|
|
|
|
"QuakeForge.Fragment.colormap",
|
|
|
|
"QuakeForge.Fragment.mdl",
|
2013-06-07 08:12:44 +00:00
|
|
|
0
|
2013-05-12 04:51:02 +00:00
|
|
|
};
|
2012-01-02 02:18:34 +00:00
|
|
|
|
|
|
|
static struct {
|
|
|
|
int program;
|
|
|
|
shaderparam_t mvp_matrix;
|
|
|
|
shaderparam_t norm_matrix;
|
2012-01-02 04:41:12 +00:00
|
|
|
shaderparam_t skin_size;
|
2012-01-04 05:35:34 +00:00
|
|
|
shaderparam_t blend;
|
|
|
|
shaderparam_t colora;
|
|
|
|
shaderparam_t colorb;
|
|
|
|
shaderparam_t sta;
|
|
|
|
shaderparam_t stb;
|
|
|
|
shaderparam_t normala;
|
|
|
|
shaderparam_t normalb;
|
|
|
|
shaderparam_t vertexa;
|
|
|
|
shaderparam_t vertexb;
|
2012-01-02 02:18:34 +00:00
|
|
|
shaderparam_t colormap;
|
|
|
|
shaderparam_t skin;
|
|
|
|
shaderparam_t ambient;
|
|
|
|
shaderparam_t shadelight;
|
|
|
|
shaderparam_t lightvec;
|
2012-01-29 01:27:28 +00:00
|
|
|
shaderparam_t fog;
|
2012-01-02 02:18:34 +00:00
|
|
|
} quake_mdl = {
|
|
|
|
0,
|
|
|
|
{"mvp_mat", 1},
|
|
|
|
{"norm_mat", 1},
|
2012-01-02 04:41:12 +00:00
|
|
|
{"skin_size", 1},
|
2012-01-04 05:35:34 +00:00
|
|
|
{"blend", 1},
|
|
|
|
{"vcolora", 0},
|
|
|
|
{"vcolorb", 0},
|
|
|
|
{"vsta", 0},
|
|
|
|
{"vstb", 0},
|
|
|
|
{"vnormala", 0},
|
|
|
|
{"vnormalb", 0},
|
|
|
|
{"vertexa", 0},
|
|
|
|
{"vertexb", 0},
|
2012-01-02 02:18:34 +00:00
|
|
|
{"colormap", 1},
|
|
|
|
{"skin", 1},
|
|
|
|
{"ambient", 1},
|
|
|
|
{"shadelight", 1},
|
|
|
|
{"lightvec", 1},
|
2012-01-29 01:27:28 +00:00
|
|
|
{"fog", 1},
|
2012-01-02 02:18:34 +00:00
|
|
|
};
|
2012-01-01 14:58:12 +00:00
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
static mat4f_t alias_vp;
|
2012-01-02 04:15:51 +00:00
|
|
|
|
2012-02-18 13:28:42 +00:00
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_InitAlias (void)
|
2012-01-01 14:58:12 +00:00
|
|
|
{
|
2013-05-12 04:51:02 +00:00
|
|
|
shader_t *vert_shader, *frag_shader;
|
2012-01-02 02:18:34 +00:00
|
|
|
int vert;
|
|
|
|
int frag;
|
2012-01-02 04:15:51 +00:00
|
|
|
|
2013-05-12 04:51:02 +00:00
|
|
|
vert_shader = GLSL_BuildShader (alias_vert_effects);
|
|
|
|
frag_shader = GLSL_BuildShader (alias_frag_effects);
|
|
|
|
vert = GLSL_CompileShader ("quakemdl.vert", vert_shader,
|
2012-02-17 09:57:13 +00:00
|
|
|
GL_VERTEX_SHADER);
|
2013-05-12 04:51:02 +00:00
|
|
|
frag = GLSL_CompileShader ("quakemdl.frag", frag_shader,
|
2012-02-17 09:57:13 +00:00
|
|
|
GL_FRAGMENT_SHADER);
|
|
|
|
quake_mdl.program = GLSL_LinkProgram ("quakemdl", vert, frag);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.mvp_matrix);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.norm_matrix);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.skin_size);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.blend);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.colora);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.colorb);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.sta);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.stb);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.normala);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.normalb);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.vertexa);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.vertexb);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.colormap);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.skin);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.ambient);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.shadelight);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.lightvec);
|
|
|
|
GLSL_ResolveShaderParam (quake_mdl.program, &quake_mdl.fog);
|
2013-05-12 04:51:02 +00:00
|
|
|
GLSL_FreeShader (vert_shader);
|
|
|
|
GLSL_FreeShader (frag_shader);
|
2012-01-01 14:58:12 +00:00
|
|
|
}
|
2012-01-03 11:36:07 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
calc_lighting (entity_t *ent, float *ambient, float *shadelight,
|
|
|
|
vec3_t lightvec)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
float add;
|
|
|
|
vec3_t dist;
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t entorigin;
|
2012-07-03 06:57:33 +00:00
|
|
|
int light;
|
2012-01-03 11:36:07 +00:00
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
entorigin = Transform_GetWorldPosition (ent->transform);
|
|
|
|
|
2012-01-03 11:36:07 +00:00
|
|
|
VectorSet ( -1, 0, 0, lightvec); //FIXME
|
2022-03-30 14:50:12 +00:00
|
|
|
light = R_LightPoint (&r_refdef.worldmodel->brush, entorigin);
|
2021-03-09 14:52:40 +00:00
|
|
|
*ambient = max (light, max (ent->renderer.model->min_light,
|
|
|
|
ent->renderer.min_light) * 128);
|
2012-01-03 11:36:07 +00:00
|
|
|
*shadelight = *ambient;
|
|
|
|
|
|
|
|
for (i = 0; i < r_maxdlights; i++) {
|
2012-02-14 08:28:09 +00:00
|
|
|
if (r_dlights[i].die >= vr_data.realtime) {
|
2021-03-19 11:18:45 +00:00
|
|
|
VectorSubtract (entorigin, r_dlights[i].origin, dist);
|
2012-01-03 11:36:07 +00:00
|
|
|
add = r_dlights[i].radius - VectorLength (dist);
|
|
|
|
if (add > 0)
|
|
|
|
*ambient += add;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (*ambient >= 128)
|
|
|
|
*ambient = 128;
|
|
|
|
if (*shadelight > 192 - *ambient)
|
|
|
|
*shadelight = 192 - *ambient;
|
|
|
|
}
|
2012-01-04 05:35:34 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
set_arrays (const shaderparam_t *vert, const shaderparam_t *norm,
|
|
|
|
const shaderparam_t *st, aliasvrt_t *pose)
|
|
|
|
{
|
|
|
|
byte *pose_offs = (byte *) pose;
|
2012-04-25 01:09:23 +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 (developer & SYS_glsl) {
|
2012-04-25 01:09:23 +00:00
|
|
|
GLint size;
|
|
|
|
|
|
|
|
qfeglGetBufferParameteriv (GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
|
2013-01-22 04:27:39 +00:00
|
|
|
if (size <= (intptr_t)pose_offs) {
|
2012-04-25 01:09:23 +00:00
|
|
|
Sys_Printf ("Invalid pose");
|
|
|
|
pose = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (vert->location, 3, GL_UNSIGNED_SHORT,
|
2012-01-04 05:35:34 +00:00
|
|
|
0, sizeof (aliasvrt_t),
|
|
|
|
pose_offs + field_offset (aliasvrt_t, vertex));
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (norm->location, 3, GL_SHORT,
|
2012-01-05 03:45:43 +00:00
|
|
|
1, sizeof (aliasvrt_t),
|
2012-01-04 05:35:34 +00:00
|
|
|
pose_offs + field_offset (aliasvrt_t, normal));
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttribPointer (st->location, 2, GL_SHORT,
|
2012-01-04 05:35:34 +00:00
|
|
|
0, sizeof (aliasvrt_t),
|
|
|
|
pose_offs + field_offset (aliasvrt_t, st));
|
|
|
|
}
|
2012-01-03 09:09:33 +00:00
|
|
|
//#define TETRAHEDRON
|
2012-01-02 10:15:01 +00:00
|
|
|
void
|
2021-07-22 06:39:28 +00:00
|
|
|
glsl_R_DrawAlias (entity_t *ent)
|
2012-01-02 10:15:01 +00:00
|
|
|
{
|
2012-01-02 14:32:30 +00:00
|
|
|
#ifdef TETRAHEDRON
|
|
|
|
static aliasvrt_t debug_verts[] = {
|
2012-01-04 00:42:00 +00:00
|
|
|
{{ 0, 0}, {-18918,-18918,-18918}, { 0, 0, 0}},
|
|
|
|
{{ 0,300}, { 18918, 18918,-18918}, {255,255, 0}},
|
|
|
|
{{300,300}, {-18918, 18918, 18918}, { 0,255,255}},
|
|
|
|
{{300, 0}, { 18918,-18918, 18918}, {255, 0,255}},
|
2012-01-02 14:32:30 +00:00
|
|
|
};
|
|
|
|
static GLushort debug_indices[] = {
|
|
|
|
0, 1, 2,
|
|
|
|
0, 3, 1,
|
|
|
|
1, 3, 2,
|
|
|
|
0, 2, 3,
|
|
|
|
};
|
|
|
|
#endif
|
2012-01-02 10:15:01 +00:00
|
|
|
static quat_t color = { 1, 1, 1, 1};
|
2012-01-03 11:36:07 +00:00
|
|
|
static vec3_t lightvec;
|
|
|
|
float ambient;
|
|
|
|
float shadelight;
|
2012-01-02 10:15:01 +00:00
|
|
|
float skin_size[2];
|
2012-01-04 07:36:43 +00:00
|
|
|
float blend;
|
2021-07-22 06:39:28 +00:00
|
|
|
animation_t *animation = &ent->animation;
|
2021-03-09 14:52:40 +00:00
|
|
|
model_t *model = ent->renderer.model;
|
2012-01-02 10:15:01 +00:00
|
|
|
aliashdr_t *hdr;
|
|
|
|
vec_t norm_mat[9];
|
2012-01-22 06:48:32 +00:00
|
|
|
int skin_tex;
|
2012-01-23 10:24:12 +00:00
|
|
|
int colormap;
|
2012-01-04 07:36:43 +00:00
|
|
|
aliasvrt_t *pose1 = 0; // VBO's are null based
|
|
|
|
aliasvrt_t *pose2 = 0; // VBO's are null based
|
2021-03-09 14:52:40 +00:00
|
|
|
mat4f_t worldMatrix;
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-01-17 02:44:28 +00:00
|
|
|
if (!(hdr = model->aliashdr))
|
|
|
|
hdr = Cache_Get (&model->cache);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-01-03 11:36:07 +00:00
|
|
|
calc_lighting (ent, &ambient, &shadelight, lightvec);
|
|
|
|
|
2021-03-09 14:52:40 +00:00
|
|
|
Transform_GetWorldMatrix (ent->transform, worldMatrix);
|
2012-01-02 10:15:01 +00:00
|
|
|
// we need only the rotation for normals.
|
2021-03-09 14:52:40 +00:00
|
|
|
VectorCopy (worldMatrix[0], norm_mat + 0);
|
|
|
|
VectorCopy (worldMatrix[1], norm_mat + 3);
|
|
|
|
VectorCopy (worldMatrix[2], norm_mat + 6);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
|
|
|
// ent model scaling and offset
|
2021-03-09 14:52:40 +00:00
|
|
|
mat4f_t mvp_mat = {
|
|
|
|
{ hdr->mdl.scale[0], 0, 0, 0 },
|
|
|
|
{ 0, hdr->mdl.scale[1], 0, 0 },
|
|
|
|
{ 0, 0, hdr->mdl.scale[2], 0 },
|
|
|
|
{ hdr->mdl.scale_origin[0], hdr->mdl.scale_origin[1],
|
|
|
|
hdr->mdl.scale_origin[2], 1 },
|
|
|
|
};
|
|
|
|
mmulf (mvp_mat, worldMatrix, mvp_mat);
|
|
|
|
mmulf (mvp_mat, alias_vp, mvp_mat);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-01-23 10:24:12 +00:00
|
|
|
colormap = glsl_colormap;
|
2021-03-09 14:52:40 +00:00
|
|
|
if (ent->renderer.skin && ent->renderer.skin->auxtex)
|
|
|
|
colormap = ent->renderer.skin->auxtex;
|
|
|
|
if (ent->renderer.skin && ent->renderer.skin->texnum) {
|
|
|
|
skin_t *skin = ent->renderer.skin;
|
2012-01-23 07:16:30 +00:00
|
|
|
skin_tex = skin->texnum;
|
2012-01-22 06:48:32 +00:00
|
|
|
} else {
|
|
|
|
maliasskindesc_t *skindesc;
|
2021-07-22 06:39:28 +00:00
|
|
|
skindesc = R_AliasGetSkindesc (animation, ent->renderer.skinnum, hdr);
|
2012-01-22 06:48:32 +00:00
|
|
|
skin_tex = skindesc->texnum;
|
|
|
|
}
|
2021-07-22 06:39:28 +00:00
|
|
|
blend = R_AliasGetLerpedFrames (animation, hdr);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2021-07-22 06:39:28 +00:00
|
|
|
pose1 += animation->pose1 * hdr->poseverts;
|
|
|
|
pose2 += animation->pose2 * hdr->poseverts;
|
2012-01-02 10:15:01 +00:00
|
|
|
|
|
|
|
skin_size[0] = hdr->mdl.skinwidth;
|
|
|
|
skin_size[1] = hdr->mdl.skinheight;
|
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
|
|
|
qfeglBindTexture (GL_TEXTURE_2D, colormap);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglBindTexture (GL_TEXTURE_2D, skin_tex);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-01-02 14:32:30 +00:00
|
|
|
#ifndef TETRAHEDRON
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglBindBuffer (GL_ARRAY_BUFFER, hdr->posedata);
|
|
|
|
qfeglBindBuffer (GL_ELEMENT_ARRAY_BUFFER, hdr->commands);
|
2012-01-02 14:32:30 +00:00
|
|
|
#endif
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglVertexAttrib4fv (quake_mdl.colora.location, color);
|
|
|
|
qfeglVertexAttrib4fv (quake_mdl.colorb.location, color);
|
|
|
|
qfeglUniform1f (quake_mdl.blend.location, blend);
|
|
|
|
qfeglUniform1f (quake_mdl.ambient.location, ambient);
|
|
|
|
qfeglUniform1f (quake_mdl.shadelight.location, shadelight);
|
|
|
|
qfeglUniform3fv (quake_mdl.lightvec.location, 1, lightvec);
|
|
|
|
qfeglUniform2fv (quake_mdl.skin_size.location, 1, skin_size);
|
2021-03-09 14:52:40 +00:00
|
|
|
qfeglUniformMatrix4fv (quake_mdl.mvp_matrix.location, 1, false,
|
2022-03-30 15:07:20 +00:00
|
|
|
(vec_t*)&mvp_mat[0]);//FIXME
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniformMatrix3fv (quake_mdl.norm_matrix.location, 1, false, norm_mat);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-01-02 14:32:30 +00:00
|
|
|
#ifndef TETRAHEDRON
|
2012-01-04 07:36:43 +00:00
|
|
|
set_arrays (&quake_mdl.vertexa, &quake_mdl.normala, &quake_mdl.sta, pose1);
|
|
|
|
set_arrays (&quake_mdl.vertexb, &quake_mdl.normalb, &quake_mdl.stb, pose2);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDrawElements (GL_TRIANGLES, 3 * hdr->mdl.numtris,
|
2012-01-04 05:35:34 +00:00
|
|
|
GL_UNSIGNED_SHORT, 0);
|
2012-01-02 14:32:30 +00:00
|
|
|
#else
|
2012-01-04 05:35:34 +00:00
|
|
|
set_arrays (&quake_mdl.vertexa, &quake_mdl.normala, &quake_mdl.sta,
|
|
|
|
debug_verts);
|
|
|
|
set_arrays (&quake_mdl.vertexb, &quake_mdl.normalb, &quake_mdl.stb,
|
|
|
|
debug_verts);
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglDrawElements (GL_TRIANGLES,
|
2012-01-02 14:32:30 +00:00
|
|
|
sizeof (debug_indices) / sizeof (debug_indices[0]),
|
|
|
|
GL_UNSIGNED_SHORT, debug_indices);
|
|
|
|
#endif
|
2012-01-17 02:44:28 +00:00
|
|
|
if (!model->aliashdr)
|
|
|
|
Cache_Release (&model->cache);
|
2012-01-02 10:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// All alias models are drawn in a batch, so avoid thrashing the gl state
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_AliasBegin (void)
|
2012-01-02 10:15:01 +00:00
|
|
|
{
|
2012-01-29 01:27:28 +00:00
|
|
|
quat_t fog;
|
|
|
|
|
2012-01-02 10:15:01 +00:00
|
|
|
// pre-multiply the view and projection matricies
|
2021-03-09 14:52:40 +00:00
|
|
|
mmulf (alias_vp, glsl_projection, glsl_view);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUseProgram (quake_mdl.program);
|
|
|
|
qfeglEnableVertexAttribArray (quake_mdl.vertexa.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_mdl.vertexb.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_mdl.normala.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_mdl.normalb.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_mdl.sta.location);
|
|
|
|
qfeglEnableVertexAttribArray (quake_mdl.stb.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.colora.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.colorb.location);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2022-03-07 17:10:47 +00:00
|
|
|
Fog_GetColor (fog);
|
|
|
|
fog[3] = Fog_GetDensity () / 64.0;
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform4fv (quake_mdl.fog.location, 1, fog);
|
2012-01-29 01:27:28 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform1i (quake_mdl.colormap.location, 1);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
|
|
|
qfeglEnable (GL_TEXTURE_2D);
|
2012-01-02 10:15:01 +00:00
|
|
|
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglUniform1i (quake_mdl.skin.location, 0);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglEnable (GL_TEXTURE_2D);
|
2012-01-02 10:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
glsl_R_AliasEnd (void)
|
2012-01-02 10:15:01 +00:00
|
|
|
{
|
2012-02-22 07:48:57 +00:00
|
|
|
qfeglBindBuffer (GL_ARRAY_BUFFER, 0);
|
|
|
|
qfeglBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
|
|
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.vertexa.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.vertexb.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.normala.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.normalb.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.sta.location);
|
|
|
|
qfeglDisableVertexAttribArray (quake_mdl.stb.location);
|
|
|
|
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 0);
|
|
|
|
qfeglDisable (GL_TEXTURE_2D);
|
|
|
|
qfeglActiveTexture (GL_TEXTURE0 + 1);
|
|
|
|
qfeglDisable (GL_TEXTURE_2D);
|
2012-01-02 10:15:01 +00:00
|
|
|
}
|