else
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.tex[0] = R_GetTexture(particlefonttexture);
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
varray_element[0] = 0;
qglColor4ub(c[0], c[1], c[2], c[3]);
if (gl_state.texture[0])
{
- v = varray_texcoord[j] + in * 2;
+ v = varray_texcoord[0] + in * 2;
qglTexCoord2f(v[0], v[1]);
}
v = varray_vertex + in * 4;
R_Mesh_Start(r_mesh_farclip);
}
+void R_Mesh_Matrix(const matrix4x4_t *matrix)
+{
+ if (memcmp(matrix, &backend_modelmatrix, sizeof(matrix4x4_t)))
+ {
+ backend_modelmatrix = *matrix;
+ Matrix4x4_Concat(&backend_modelviewmatrix, &backend_viewmatrix, matrix);
+ Matrix4x4_Transpose(&backend_glmodelviewmatrix, &backend_modelviewmatrix);
+ qglLoadMatrixf(&backend_glmodelviewmatrix.m[0][0]);
+ }
+}
+
// sets up the requested state
void R_Mesh_State(const rmeshstate_t *m)
{
GL_SetupTextureState();
}
- //backendmatrix = m->matrix; // this copies the struct
- if (memcmp(&m->matrix, &backend_modelmatrix, sizeof(matrix4x4_t)))
- {
- backend_modelmatrix = m->matrix;
- Matrix4x4_Concat(&backend_modelviewmatrix, &backend_viewmatrix, &m->matrix);
- Matrix4x4_Transpose(&backend_glmodelviewmatrix, &backend_modelviewmatrix);
- qglLoadMatrixf(&backend_glmodelviewmatrix.m[0][0]);
- }
-
overbright = false;
scaler = 1;
if (m->blendfunc1 == GL_DST_COLOR)
int wantoverbright;
int tex[MAX_TEXTUREUNITS];
int texrgbscale[MAX_TEXTUREUNITS]; // used only if COMBINE is present
- matrix4x4_t matrix; // model to world transform matrix
}
rmeshstate_t;
// (only valid between R_Mesh_Start and R_Mesh_Finish)
void R_Mesh_ClearDepth(void);
+// sets up the requested transform matrix
+void R_Mesh_Matrix(const matrix4x4_t *matrix);
+
// sets up the requested state
void R_Mesh_State(const rmeshstate_t *m);
int blendfunc1, blendfunc2;
// softwaretransformforentity(ent);
+ R_Mesh_Matrix(&ent->matrix);
fog = 0;
if (fogenabled)
m.blendfunc2 = blendfunc2;
m.wantoverbright = true;
m.tex[0] = R_GetTexture(r_notexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
c_alias_polys += model->numtris;
m.blendfunc2 = blendfunc2;
m.wantoverbright = true;
m.tex[0] = R_GetTexture(skinframe->merged);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
c_alias_polys += model->numtris;
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
m.wantoverbright = true;
- m.matrix = ent->matrix;
m.tex[0] = colormapped ? R_GetTexture(skinframe->base) : R_GetTexture(skinframe->merged);
if (m.tex[0])
{
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
m.wantoverbright = true;
- m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->pants);
if (m.tex[0])
{
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
m.wantoverbright = true;
- m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->shirt);
if (m.tex[0])
{
m.blendfunc1 = blendfunc1;
m.blendfunc2 = blendfunc2;
m.wantoverbright = true;
- m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->glow);
if (m.tex[0])
{
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
m.wantoverbright = false;
- m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(skinframe->fog);
R_Mesh_State(&m);
int shadernum = calldata2;
int numverts, numtriangles;
+ R_Mesh_Matrix(&ent->matrix);
+
// find the vertex index list and texture
m = ent->model->zymdata_header;
renderlist = (int *)(m->lump_render.start + (int) m);
mstate.blendfunc2 = GL_ZERO;
}
mstate.tex[0] = R_GetTexture(texture);
- mstate.matrix = ent->matrix;
R_Mesh_State(&mstate);
c_alias_polys += numtriangles;
mstate.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
// FIXME: need alpha mask for fogging...
//mstate.tex[0] = R_GetTexture(texture);
- mstate.matrix = ent->matrix;
R_Mesh_State(&mstate);
c_alias_polys += numtriangles;
mplane_t frustum[4];
+matrix4x4_t r_identitymatrix;
+
int c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights;
// true during envmap command capture
void GL_Main_Init(void)
{
+ Matrix4x4_CreateIdentity(&r_identitymatrix);
// FIXME: move this to client?
FOG_registercvars();
Cmd_AddCommand ("timerefresh", R_TimeRefresh_f);
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.wantoverbright = false;
m.depthdisable = true; // magic
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
varray_element[0] = 0;
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.wantoverbright = false;
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
varray_element
m.blendfunc2 = GL_ZERO;
}
m.wantoverbright = false;
- m.matrix = ent->matrix;
+ R_Mesh_Matrix(&ent->matrix);
R_Mesh_State(&m);
varray_element[ 0] = 5;varray_element[ 1] = 2;varray_element[ 2] = 0;
R_Sky();
}
+ R_Mesh_Matrix(&ent->matrix);
+
// draw depth-only polys
memset(&m, 0, sizeof(m));
if (skyrendermasked)
}
m.wantoverbright = false;
m.depthwrite = true;
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (surf = firstsurf;surf;surf = surf->chain)
{
float modelorg[3];
Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg);
+ R_Mesh_Matrix(&ent->matrix);
+
memset(&m, 0, sizeof(m));
if (ent->effects & EF_ADDITIVE)
{
}
m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_ONE;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
R_MeshQueue_AddTransparent(center, RSurfShader_Water_Callback, ent, surf - ent->model->surfaces);
}
else
- R_MeshQueue_Add(RSurfShader_Water_Callback, ent, surf - ent->model->surfaces);
+ RSurfShader_Water_Callback(ent, surf - ent->model->surfaces);
}
}
m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
}
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_ONE;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE;
m.wantoverbright = false;
- m.matrix = ent->matrix;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
m.texrgbscale[1] = 4.0f;
m.tex[2] = R_GetTexture(surf->currenttexture->detailtexture);
m.texrgbscale[2] = 2.0f;
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
m.tex[1] = R_GetTexture(surf->lightmaptexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_ZERO;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_SRC_COLOR;
m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->lightmaptexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_ONE;
m.wantoverbright = true;
m.tex[0] = R_GetTexture(surf->currenttexture->texture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_SRC_COLOR;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->detailtexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
m.blendfunc2 = GL_ONE;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
- m.matrix = ent->matrix;
R_Mesh_State(&m);
for (mesh = surf->mesh;mesh;mesh = mesh->chain)
{
{
const entity_render_t *ent = calldata1;
const msurface_t *surf = ent->model->surfaces + calldata2;
+ R_Mesh_Matrix(&ent->matrix);
RSurfShader_Wall_Pass_BaseFullbright(ent, surf);
if (surf->currenttexture->glowtexture)
RSurfShader_Wall_Pass_Glow(ent, surf);
{
const entity_render_t *ent = calldata1;
const msurface_t *surf = ent->model->surfaces + calldata2;
+ R_Mesh_Matrix(&ent->matrix);
RSurfShader_Wall_Pass_BaseVertex(ent, surf);
if (surf->currenttexture->glowtexture)
RSurfShader_Wall_Pass_Glow(ent, surf);
if (!ent->model)
return;
+ R_Mesh_Matrix(&ent->matrix);
+
for (i = 0;i < Cshader_count;i++)
Cshaders[i]->chain = NULL;
m.blendfunc1 = GL_SRC_ALPHA;
m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
m.wantoverbright = false;
- m.matrix = ent->matrix;
+ R_Mesh_Matrix(&ent->matrix);
R_Mesh_State(&m);
R_Mesh_ResizeCheck(portal->numpoints, portal->numpoints - 2);
for (i = 0;i < mesh->numtriangles;i++)
#this is used to ensure that all released versions are free of warnings.
#normal compile
-#OPTIMIZATIONS= -O6 -fno-strict-aliasing -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
-#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include $(OPTIMIZATIONS) $(PROFILEOPTION)
+OPTIMIZATIONS= -O6 -fno-strict-aliasing -ffast-math -funroll-loops $(NOPROFILEOPTIMIZATIONS) -fexpensive-optimizations $(CPUOPTIMIZATIONS)
+CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include $(OPTIMIZATIONS) $(PROFILEOPTION)
#debug compile
-OPTIMIZATIONS=
-CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
+#OPTIMIZATIONS=
+#CFLAGS= -MD -Wall -Werror -I/usr/X11R6/include -ggdb $(OPTIMIZATIONS) $(PROFILEOPTION)
LDFLAGS= -L/usr/X11R6/lib -lm -lX11 -lXext -lXxf86dga -lXxf86vm -ldl $(SOUNDLIB) $(PROFILEOPTION)
m.wantoverbright = false;
m.depthdisable = true;
m.tex[0] = R_GetTexture(texture);
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
varray_element[0] = 0;
m.blendfunc2 = GL_ONE;
m.wantoverbright = false;
m.tex[0] = R_GetTexture(explosiontexture);
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
numtriangles = EXPLOSIONTRIS;
m.wantoverbright = false;
m.depthdisable = true; // magic
m.tex[0] = R_GetTexture(lightcorona);
- Matrix4x4_CreateIdentity(&m.matrix);
+ R_Mesh_Matrix(&r_identitymatrix);
R_Mesh_State(&m);
viewdist = DotProduct(r_origin, vpn);
for (i = 0;i < r_numdlights;i++)
m.wantoverbright = false;
m.depthdisable = true; // don't modify or read zbuffer
m.tex[0] = R_GetTexture(skyboxside[3]); // front
- Matrix4x4_CreateTranslate(&m.matrix, r_origin[0], r_origin[1], r_origin[2]);
R_Mesh_State(&m);
memcpy(varray_element, skyboxindex, sizeof(int[6]));
m.wantoverbright = false;
m.depthdisable = true; // don't modify or read zbuffer
m.tex[0] = R_GetTexture(solidskytexture);
- Matrix4x4_CreateTranslate(&m.matrix, r_origin[0], r_origin[1], r_origin[2]);
R_Mesh_State(&m);
memcpy(varray_element, skysphereindices, numtriangles * sizeof(int[3]));
void R_Sky(void)
{
+ matrix4x4_t skymatrix;
if (skyrendermasked)
{
+ Matrix4x4_CreateTranslate(&skymatrix, r_origin[0], r_origin[1], r_origin[2]);
+ R_Mesh_Matrix(&skymatrix);
if (skyrendersphere)
{
// this does not modify depth buffer
m.blendfunc2 = GL_ONE;
m.wantoverbright = wantoverbright;
m.tex[0] = texture;
- Matrix4x4_CreateIdentity(&m.matrix);
R_Mesh_State(&m);
varray_element[0] = 0;
if (R_SpriteSetup(ent, ent->model->sprnum_type, org, left, up))
return;
+ R_Mesh_Matrix(&r_identitymatrix);
+
if ((ent->model->flags & EF_FULLBRIGHT) || (ent->effects & EF_FULLBRIGHT))
{
color[0] = color[1] = color[2] = 1;
#ifndef RENDER_H
#define RENDER_H
+extern matrix4x4_t r_identitymatrix;
+
// 1.0f / N table
extern float ixtable[4096];