From eab50b35822052aad2a31fece513583600e5941f Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 10 Mar 2004 08:35:53 +0000 Subject: [PATCH] R_Mesh_State_Texture and GL_VertexPointer merge once again to become the reborn R_Mesh_State function git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4002 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_particles.c | 4 +- gl_backend.c | 23 ++++---- gl_backend.h | 6 +- gl_draw.c | 15 ++--- gl_models.c | 12 ++-- gl_rmain.c | 14 ++--- gl_rsurf.c | 157 ++++++++++++++++++++++--------------------------- r_explosion.c | 4 +- r_lightning.c | 4 +- r_shadow.c | 126 +++++++++++++++++++++++---------------- r_sky.c | 12 ++-- 11 files changed, 190 insertions(+), 187 deletions(-) diff --git a/cl_particles.c b/cl_particles.c index aa458a27..358d96ec 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -1885,7 +1885,8 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(tex->texture); m.pointer_texcoord[0] = particle_texcoord2f; - R_Mesh_State_Texture(&m); + m.pointer_vertex = particle_vertex3f; + R_Mesh_State(&m); if (p->blendmode == 0) GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -1895,7 +1896,6 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2) GL_BlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); GL_DepthMask(false); GL_DepthTest(true); - GL_VertexPointer(particle_vertex3f); #endif if (p->orientation == PARTICLE_BILLBOARD || p->orientation == PARTICLE_ORIENTED_DOUBLESIDED) { diff --git a/gl_backend.c b/gl_backend.c index d562789d..aae2f1de 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -561,17 +561,6 @@ void GL_ColorMask(int r, int g, int b, int a) } } -void GL_VertexPointer(const float *p) -{ - if (gl_state.pointer_vertex != p) - { - gl_state.pointer_vertex = p; - CHECKGLERROR - qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), gl_state.pointer_vertex); - CHECKGLERROR - } -} - void GL_ColorPointer(const float *p) { if (gl_state.pointer_color != p) @@ -909,13 +898,21 @@ void R_Mesh_TextureMatrix(int unitnumber, const matrix4x4_t *matrix) } } -void R_Mesh_State_Texture(const rmeshstate_t *m) +void R_Mesh_State(const rmeshstate_t *m) { int i, combinergb, combinealpha, scale, arrayis3d; gltextureunit_t *unit; BACKENDACTIVECHECK + if (gl_state.pointer_vertex != m->pointer_vertex) + { + gl_state.pointer_vertex = m->pointer_vertex; + CHECKGLERROR + qglVertexPointer(3, GL_FLOAT, sizeof(float[3]), gl_state.pointer_vertex); + CHECKGLERROR + } + if (gl_backend_rebindtextures) { gl_backend_rebindtextures = false; @@ -1259,7 +1256,7 @@ showtris: GL_DepthTest(GL_FALSE); GL_DepthMask(GL_FALSE); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); r_showtrispass = true; GL_ShowTrisColor(0.2,0.2,0.2,1); goto showtris; diff --git a/gl_backend.h b/gl_backend.h index 6b50d079..705d2922 100644 --- a/gl_backend.h +++ b/gl_backend.h @@ -16,7 +16,6 @@ void GL_BlendFunc(int blendfunc1, int blendfunc2); void GL_DepthMask(int state); void GL_DepthTest(int state); void GL_ColorMask(int r, int g, int b, int a); -void GL_VertexPointer(const float *p); void GL_ColorPointer(const float *p); void GL_Color(float cr, float cg, float cb, float ca); void GL_ShowTrisColor(float cr, float cg, float cb, float ca); @@ -50,6 +49,9 @@ typedef struct int texcombinealpha[MAX_TEXTUREUNITS]; // does nothing without combine // pointers const float *pointer_texcoord[MAX_TEXTUREUNITS]; + + // other state set by this + const float *pointer_vertex; } rmeshstate_t; @@ -70,7 +72,7 @@ void R_Mesh_Matrix(const matrix4x4_t *matrix); void R_Mesh_TextureMatrix(int unitnumber, const matrix4x4_t *matrix); // set up the requested state -void R_Mesh_State_Texture(const rmeshstate_t *m); +void R_Mesh_State(const rmeshstate_t *m); // renders a mesh void R_Mesh_Draw(int numverts, int numtriangles, const int *elements); diff --git a/gl_draw.c b/gl_draw.c index b488ba11..358c7251 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -426,8 +426,6 @@ void R_DrawQueue(void) chartexnum = R_GetTexture(char_texture); memset(&m, 0, sizeof(m)); - m.tex[0] = 0; - R_Mesh_State_Texture(&m); currentpic = ""; pic = NULL; @@ -475,9 +473,9 @@ void R_DrawQueue(void) m.tex[0] = chartexnum; } batchcount = 0; - GL_VertexPointer(varray_vertex3f); + m.pointer_vertex = varray_vertex3f; m.pointer_texcoord[0] = varray_texcoord2f[0]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); at = varray_texcoord2f[0]; av = varray_vertex3f; while ((num = *str++) && x < vid.conwidth) @@ -514,11 +512,11 @@ void R_DrawQueue(void) break; case DRAWQUEUE_MESH: mesh = (void *)(dq + 1); - GL_VertexPointer(mesh->data_vertex3f); + m.pointer_vertex = mesh->data_vertex3f; GL_ColorPointer(mesh->data_color4f); m.tex[0] = R_GetTexture(mesh->texture); m.pointer_texcoord[0] = mesh->data_texcoord2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i); GL_ColorPointer(NULL); currentpic = "\0"; @@ -548,7 +546,8 @@ void R_DrawQueue(void) { // all the blends ignore depth memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = blendvertex3f; + R_Mesh_State(&m); GL_DepthMask(true); GL_DepthTest(false); if (v_color_enable.integer) @@ -562,7 +561,6 @@ void R_DrawQueue(void) if (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f) { GL_BlendFunc(GL_DST_COLOR, GL_ONE); - GL_VertexPointer(blendvertex3f); while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f) { GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1); @@ -581,7 +579,6 @@ void R_DrawQueue(void) if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f) { GL_BlendFunc(GL_ONE, GL_ONE); - GL_VertexPointer(blendvertex3f); GL_Color(c[0], c[1], c[2], 1); R_Mesh_Draw(3, 1, polygonelements); } diff --git a/gl_models.c b/gl_models.c index 17e1f2bf..1205ff24 100644 --- a/gl_models.c +++ b/gl_models.c @@ -234,10 +234,10 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2) m.texrgbscale[0] = 4; } } - R_Mesh_State_Texture(&m); + m.pointer_vertex = varray_vertex3f; + R_Mesh_State(&m); c_alias_polys += mesh->num_triangles; - GL_VertexPointer(varray_vertex3f); R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, varray_vertex3f); if (layer->flags & ALIASLAYER_FOG) { @@ -739,7 +739,6 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) GL_DepthMask(true); } GL_DepthTest(true); - GL_VertexPointer(varray_vertex3f); memset(&mstate, 0, sizeof(mstate)); colorscale = 1.0f; @@ -750,7 +749,8 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) } mstate.tex[0] = R_GetTexture(texture); mstate.pointer_texcoord[0] = ent->model->alias.zymdata_texcoords; - R_Mesh_State_Texture(&mstate); + mstate.pointer_vertex = varray_vertex3f; + R_Mesh_State(&mstate); ZymoticLerpBones(ent->model->alias.zymnum_bones, (zymbonematrix *) ent->model->alias.zymdata_poses, ent->frameblend, ent->model->alias.zymdata_bones); @@ -774,13 +774,13 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2) GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_DepthMask(false); GL_DepthTest(true); - GL_VertexPointer(varray_vertex3f); memset(&mstate, 0, sizeof(mstate)); // FIXME: need alpha mask for fogging... //mstate.tex[0] = R_GetTexture(texture); //mstate.pointer_texcoord = ent->model->alias.zymdata_texcoords; - R_Mesh_State_Texture(&mstate); + mstate.pointer_vertex = varray_vertex3f; + R_Mesh_State(&mstate); GL_ColorPointer(NULL); GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha * fog); diff --git a/gl_rmain.c b/gl_rmain.c index 5216f4b2..e0be503c 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -558,12 +558,12 @@ static void R_BlendView(void) R_Mesh_Matrix(&r_identitymatrix); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = vertex3f; + R_Mesh_State(&m); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_DepthMask(true); GL_DepthTest(false); // magic - GL_VertexPointer(vertex3f); GL_ColorPointer(NULL); GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]); r = 64; @@ -765,7 +765,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa R_Mesh_Matrix(&r_identitymatrix); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_GetSpace(8); vertex3f[ 0] = mins[0];vertex3f[ 1] = mins[1];vertex3f[ 2] = mins[2]; @@ -836,7 +836,8 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2) R_Mesh_Matrix(&ent->matrix); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = nomodelvertex3f; + R_Mesh_State(&m); if (ent->flags & EF_ADDITIVE) { @@ -854,7 +855,6 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2) GL_DepthMask(true); } GL_DepthTest(true); - GL_VertexPointer(nomodelvertex3f); if (fogenabled) { memcpy(color4f, nomodelcolor4f, sizeof(float[6*4])); @@ -937,7 +937,6 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, int depth R_Mesh_Matrix(&r_identitymatrix); GL_ColorPointer(NULL); GL_Color(cr, cg, cb, ca); - GL_VertexPointer(varray_vertex3f); GL_BlendFunc(blendfunc1, blendfunc2); GL_DepthMask(false); GL_DepthTest(!depthdisable); @@ -945,7 +944,8 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, int depth memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(texture); m.pointer_texcoord[0] = spritetexcoord2f; - R_Mesh_State_Texture(&m); + m.pointer_vertex = varray_vertex3f; + R_Mesh_State(&m); varray_vertex3f[ 0] = origin[0] + left[0] * scalex2 + up[0] * scaley1; varray_vertex3f[ 1] = origin[1] + left[1] * scalex2 + up[1] * scaley1; diff --git a/gl_rsurf.c b/gl_rsurf.c index cdf1ee55..8f9ef9f7 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -763,14 +763,14 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture GL_DepthMask(true); GL_DepthTest(true); - memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); while((surf = *surfchain++) != NULL) { if (surf->visframe == r_framecount) { - GL_VertexPointer(surf->mesh.data_vertex3f); + memset(&m, 0, sizeof(m)); + m.pointer_vertex = surf->mesh.data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -850,11 +850,11 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2) qglEnable (GL_TEXTURE_SHADER_NV); } - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; m.pointer_texcoord[1] = surf->mesh.data_texcoordtexture2f; m.texcombinergb[1] = GL_REPLACE; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); if (fogenabled) { R_FillColors(varray_color4f, surf->mesh.num_vertices, 1, 1, 1, alpha); @@ -871,14 +871,14 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2) if (fogenabled) { memset(&m, 0, sizeof(m)); + m.pointer_vertex = surf->mesh.data_vertex3f; GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); GL_DepthTest(true); m.tex[0] = R_GetTexture(texture->skin.fog); - GL_VertexPointer(surf->mesh.data_vertex3f); m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; GL_ColorPointer(varray_color4f); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); RSurf_FogPassColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], alpha, 1, surf->mesh.num_vertices, modelorg); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } @@ -946,9 +946,9 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m GL_DepthTest(true); GL_ColorPointer(varray_color4f); - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_FillColors(varray_color4f, surf->mesh.num_vertices, base, base, base, currentalpha); if (!(ent->effects & EF_FULLBRIGHT)) { @@ -973,10 +973,10 @@ static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurfac m.tex[0] = R_GetTexture(texture->skin.glow); GL_ColorPointer(varray_color4f); - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; if (m.tex[0]) m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); RSurf_FoggedColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, 1, 1, 1, currentalpha, 1, surf->mesh.num_vertices, modelorg); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } @@ -993,10 +993,10 @@ static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface m.tex[0] = R_GetTexture(texture->skin.fog); GL_ColorPointer(varray_color4f); - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; if (m.tex[0]) m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); RSurf_FogPassColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], currentalpha, 1, surf->mesh.num_vertices, modelorg); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } @@ -1031,17 +1031,13 @@ static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetailGlow(co if (surf->visframe == r_framecount) { lightmaptexturenum = R_GetTexture(surf->lightmaptexture); - //if (m.tex[1] != lightmaptexturenum) - //{ - m.tex[1] = lightmaptexturenum; - // R_Mesh_State_Texture(&m); - //} - GL_VertexPointer(surf->mesh.data_vertex3f); + m.tex[1] = lightmaptexturenum; + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; m.pointer_texcoord[1] = surf->mesh.data_texcoordlightmap2f; m.pointer_texcoord[2] = surf->mesh.data_texcoorddetail2f; m.pointer_texcoord[3] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1072,16 +1068,12 @@ static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetail(const if (surf->visframe == r_framecount) { lightmaptexturenum = R_GetTexture(surf->lightmaptexture); - //if (m.tex[1] != lightmaptexturenum) - //{ - m.tex[1] = lightmaptexturenum; - // R_Mesh_State_Texture(&m); - //} - GL_VertexPointer(surf->mesh.data_vertex3f); + m.tex[1] = lightmaptexturenum; + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; m.pointer_texcoord[1] = surf->mesh.data_texcoordlightmap2f; m.pointer_texcoord[2] = surf->mesh.data_texcoorddetail2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1109,15 +1101,11 @@ static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmap(const entity if (surf->visframe == r_framecount) { lightmaptexturenum = R_GetTexture(surf->lightmaptexture); - //if (m.tex[1] != lightmaptexturenum) - //{ - m.tex[1] = lightmaptexturenum; - // R_Mesh_State_Texture(&m); - //} - GL_VertexPointer(surf->mesh.data_vertex3f); + m.tex[1] = lightmaptexturenum; + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; m.pointer_texcoord[1] = surf->mesh.data_texcoordlightmap2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1141,9 +1129,9 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent, { if (surf->visframe == r_framecount) { - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1166,14 +1154,10 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent, if (surf->visframe == r_framecount) { lightmaptexturenum = R_GetTexture(surf->lightmaptexture); - //if (m.tex[0] != lightmaptexturenum) - //{ - m.tex[0] = lightmaptexturenum; - // R_Mesh_State_Texture(&m); - //} - GL_VertexPointer(surf->mesh.data_vertex3f); + m.tex[0] = lightmaptexturenum; + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordlightmap2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1194,10 +1178,10 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const te { if (surf->visframe == r_framecount) { - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; if (m.tex[0]) m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); RSurf_FogPassColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, fogcolor[0], fogcolor[1], fogcolor[2], 1, 1, surf->mesh.num_vertices, modelorg); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } @@ -1219,9 +1203,9 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c { if (surf->visframe == r_framecount) { - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoorddetail2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1242,9 +1226,9 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const t { if (surf->visframe == r_framecount) { - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1268,9 +1252,9 @@ static void RSurfShader_OpaqueWall_Pass_OpaqueGlow(const entity_render_t *ent, c { if (surf->visframe == r_framecount) { - GL_VertexPointer(surf->mesh.data_vertex3f); + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1297,14 +1281,10 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmapOnly(const entity_render_t * if (surf->visframe == r_framecount) { lightmaptexturenum = R_GetTexture(surf->lightmaptexture); - //if (m.tex[0] != lightmaptexturenum) - //{ - m.tex[0] = lightmaptexturenum; - // R_Mesh_State_Texture(&m); - //} - GL_VertexPointer(surf->mesh.data_vertex3f); + m.tex[0] = lightmaptexturenum; + m.pointer_vertex = surf->mesh.data_vertex3f; m.pointer_texcoord[0] = surf->mesh.data_texcoordlightmap2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i); } } @@ -1554,10 +1534,10 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2) GL_DepthMask(false); GL_DepthTest(true); R_Mesh_Matrix(&ent->matrix); - GL_VertexPointer(varray_vertex3f); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = varray_vertex3f; + R_Mesh_State(&m); i = portal - ent->model->brushq1.portals; GL_ColorPointer(NULL); @@ -2045,22 +2025,28 @@ void R_Model_Brush_DrawLight(entity_render_t *ent, vec3_t relativelightorigin, v void R_DrawCollisionBrush(colbrushf_t *brush) { int i; + rmeshstate_t m; + memset(&m, 0, sizeof(m)); + m.pointer_vertex = brush->points->v; + R_Mesh_State(&m); i = ((int)brush) / sizeof(colbrushf_t); GL_ColorPointer(NULL); GL_Color((i & 31) * (1.0f / 32.0f), ((i >> 5) & 31) * (1.0f / 32.0f), ((i >> 10) & 31) * (1.0f / 32.0f), 0.2f); - GL_VertexPointer(brush->points->v); R_Mesh_Draw(brush->numpoints, brush->numtriangles, brush->elements); } void R_Q3BSP_DrawCollisionFace(entity_render_t *ent, q3mface_t *face) { int i; + rmeshstate_t m; if (!face->num_collisiontriangles) return; + memset(&m, 0, sizeof(m)); + m.pointer_vertex = face->data_collisionvertex3f; + R_Mesh_State(&m); i = ((int)face) / sizeof(q3mface_t); GL_ColorPointer(NULL); GL_Color((i & 31) * (1.0f / 32.0f), ((i >> 5) & 31) * (1.0f / 32.0f), ((i >> 10) & 31) * (1.0f / 32.0f), 0.2f); - GL_VertexPointer(face->data_collisionvertex3f); R_Mesh_Draw(face->num_collisionvertices, face->num_collisiontriangles, face->data_collisionelement3i); } @@ -2098,9 +2084,9 @@ void R_Q3BSP_DrawSkyFace(entity_render_t *ent, q3mface_t *face) GL_DepthTest(true); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); - GL_VertexPointer(face->data_vertex3f); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); GL_ColorMask(1,1,1,1); } @@ -2121,8 +2107,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_OpaqueGlow(entity_render_t *ent, q3mface_t } else GL_Color(0, 0, 0, 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2140,8 +2126,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureLightmapCombine(entity_render_t *en m.texrgbscale[1] = 2; GL_ColorPointer(NULL); GL_Color(1, 1, 1, 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2156,8 +2142,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_Texture(entity_render_t *ent, q3mface_t *f m.pointer_texcoord[0] = face->data_texcoordtexture2f; GL_ColorPointer(NULL); GL_Color(1, 1, 1, 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2172,8 +2158,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_Lightmap(entity_render_t *ent, q3mface_t * m.pointer_texcoord[0] = face->data_texcoordlightmap2f; GL_ColorPointer(NULL); GL_Color(1, 1, 1, 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2191,8 +2177,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_LightmapOnly(entity_render_t *ent, q3mface GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1); else GL_Color(1, 1, 1, 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2212,8 +2198,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(entity_render_t *ent, q3mface_t *face } else GL_Color(0, 0, 0, 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2249,8 +2235,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureVertex(entity_render_t *ent, q3mfac } GL_ColorPointer(varray_color4f); } - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2263,7 +2249,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_VertexOnly(entity_render_t *ent, q3mface_t GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(true); GL_DepthTest(true); - R_Mesh_State_Texture(&m); mul = 2.0f; if (r_shadow_realtime_world.integer && r_shadow_realtime_world_lightmaps.value != 1) mul *= r_shadow_realtime_world_lightmaps.value; @@ -2280,7 +2265,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_VertexOnly(entity_render_t *ent, q3mface_t } GL_ColorPointer(varray_color4f); } - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2295,8 +2281,8 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_AddTextureAmbient(entity_render_t *ent, q3 m.pointer_texcoord[0] = face->data_texcoordtexture2f; GL_ColorPointer(NULL); GL_Color(r_ambient.value * (1.0f / 128.0f), r_ambient.value * (1.0f / 128.0f), r_ambient.value * (1.0f / 128.0f), 1); - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); } @@ -2356,8 +2342,8 @@ void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int facenumber) } GL_ColorPointer(varray_color4f); } - R_Mesh_State_Texture(&m); - GL_VertexPointer(face->data_vertex3f); + m.pointer_vertex = face->data_vertex3f; + R_Mesh_State(&m); qglDisable(GL_CULL_FACE); R_Mesh_Draw(face->num_vertices, face->num_triangles, face->data_element3i); qglEnable(GL_CULL_FACE); @@ -2530,12 +2516,9 @@ void R_Q3BSP_Draw(entity_render_t *ent) } if (r_drawcollisionbrushes.integer >= 1) { - rmeshstate_t m; - memset(&m, 0, sizeof(m)); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); GL_DepthTest(true); - R_Mesh_State_Texture(&m); qglPolygonOffset(r_drawcollisionbrushes_polygonfactor.value, r_drawcollisionbrushes_polygonoffset.value); for (i = 0;i < model->brushq3.data_thismodel->numbrushes;i++) if (model->brushq3.data_thismodel->firstbrush[i].colbrushf && model->brushq3.data_thismodel->firstbrush[i].colbrushf->numtriangles) diff --git a/r_explosion.c b/r_explosion.c index 775fa238..267e0928 100644 --- a/r_explosion.c +++ b/r_explosion.c @@ -190,12 +190,12 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2) alpha = e->alpha; GL_ColorPointer(NULL); GL_Color(alpha, alpha, alpha, 1); - GL_VertexPointer(e->vert[0]); memset(&m, 0, sizeof(m)); m.tex[0] = R_GetTexture(explosiontexture); m.pointer_texcoord[0] = explosiontexcoord2f[0]; - R_Mesh_State_Texture(&m); + m.pointer_vertex = e->vert[0]; + R_Mesh_State(&m); R_Mesh_Draw(numverts, numtriangles, explosiontris[0]); } diff --git a/r_lightning.c b/r_lightning.c index 91625600..5108a735 100644 --- a/r_lightning.c +++ b/r_lightning.c @@ -281,7 +281,8 @@ void R_DrawLightningBeamCallback(const void *calldata1, int calldata2) else m.tex[0] = R_GetTexture(r_lightningbeamtexture); m.pointer_texcoord[0] = varray_texcoord2f[0]; - R_Mesh_State_Texture(&m); + m.pointer_vertex = varray_vertex3f; + R_Mesh_State(&m); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); @@ -305,7 +306,6 @@ void R_DrawLightningBeamCallback(const void *calldata1, int calldata2) R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 0, t1, t2); R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 8, t1 + 0.33, t2 + 0.33); R_CalcLightningBeamPolygonTexCoord2f(varray_texcoord2f[0] + 16, t1 + 0.66, t2 + 0.66); - GL_VertexPointer(varray_vertex3f); if (fogenabled) { diff --git a/r_shadow.c b/r_shadow.c index 17d8234f..55a8d771 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -540,7 +540,10 @@ void R_Shadow_VolumeFromSphere(int numverts, int numtris, const float *invertex3 void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *vertex3f, const int *element3i) { - GL_VertexPointer(vertex3f); + rmeshstate_t m; + memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; + R_Mesh_State(&m); if (r_shadowstage == SHADOWSTAGE_STENCIL) { // decrement stencil if frontface is behind depthbuffer @@ -561,25 +564,24 @@ void R_Shadow_RenderVolume(int numvertices, int numtriangles, const float *verte void R_Shadow_RenderShadowMeshVolume(shadowmesh_t *firstmesh) { shadowmesh_t *mesh; - if (r_shadowstage == SHADOWSTAGE_STENCIL) + rmeshstate_t m; + memset(&m, 0, sizeof(m)); + for (mesh = firstmesh;mesh;mesh = mesh->next) { - // decrement stencil if frontface is behind depthbuffer - qglCullFace(GL_FRONT); // quake is backwards, this culls back faces - qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP); - for (mesh = firstmesh;mesh;mesh = mesh->next) + m.pointer_vertex = mesh->vertex3f; + R_Mesh_State(&m); + if (r_shadowstage == SHADOWSTAGE_STENCIL) { - GL_VertexPointer(mesh->vertex3f); + // decrement stencil if frontface is behind depthbuffer + qglCullFace(GL_FRONT); // quake is backwards, this culls back faces + qglStencilOp(GL_KEEP, GL_DECR, GL_KEEP); R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->element3i); c_rtcached_shadowmeshes++; c_rtcached_shadowtris += mesh->numtriangles; + // increment stencil if backface is behind depthbuffer + qglCullFace(GL_BACK); // quake is backwards, this culls front faces + qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP); } - // increment stencil if backface is behind depthbuffer - qglCullFace(GL_BACK); // quake is backwards, this culls front faces - qglStencilOp(GL_KEEP, GL_INCR, GL_KEEP); - } - for (mesh = firstmesh;mesh;mesh = mesh->next) - { - GL_VertexPointer(mesh->vertex3f); R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->element3i); c_rtcached_shadowmeshes++; c_rtcached_shadowtris += mesh->numtriangles; @@ -734,7 +736,7 @@ void R_Shadow_Stage_Begin(void) GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(false); GL_DepthTest(true); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorPointer(NULL); GL_Color(0, 0, 0, 1); qglCullFace(GL_FRONT); // quake is backwards, this culls back faces @@ -766,7 +768,7 @@ void R_Shadow_Stage_ShadowVolumes(void) { rmeshstate_t m; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorPointer(NULL); GL_Color(1, 1, 1, 1); GL_ColorMask(0, 0, 0, 0); @@ -817,7 +819,7 @@ void R_Shadow_Stage_LightWithoutShadows(void) { rmeshstate_t m; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); GL_DepthTest(true); @@ -842,7 +844,7 @@ void R_Shadow_Stage_LightWithShadows(void) { rmeshstate_t m; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); GL_DepthTest(true); @@ -869,7 +871,7 @@ void R_Shadow_Stage_End(void) { rmeshstate_t m; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(true); GL_DepthTest(true); @@ -1188,7 +1190,6 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element int renders; float color[3], color2[3]; rmeshstate_t m; - GL_VertexPointer(vertex3f); if (gl_dot3arb && gl_texturecubemap && gl_combine.integer && gl_stencil) { if (!bumptexture) @@ -1203,6 +1204,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element { // 3/2 3D combine path (Geforce3, Radeon 8500) memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.tex3d[2] = R_GetTexture(r_shadow_attenuation3dtexture); @@ -1211,7 +1213,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; m.pointer_texcoord[2] = varray_texcoord3f[2]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); GL_BlendFunc(GL_ONE, GL_ZERO); R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin); @@ -1221,6 +1223,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(basetexture); m.pointer_texcoord[0] = texcoord2f; if (lightcubemap) @@ -1229,7 +1232,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[1] = varray_texcoord3f[1]; R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight); } - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2); @@ -1248,9 +1251,10 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element { // 1/2/2 3D combine path (original Radeon) memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture); m.pointer_texcoord[0] = varray_texcoord3f[0]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); GL_BlendFunc(GL_ONE, GL_ZERO); R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0], numverts, vertex3f, matrix_modeltoattenuationxyz); @@ -1259,13 +1263,14 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[0] = GL_REPLACE; m.texcombinergb[1] = GL_DOT3_RGBA_ARB; m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_DST_ALPHA, GL_ZERO); R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin); R_Mesh_Draw(numverts, numtriangles, elements); @@ -1273,6 +1278,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(basetexture); m.pointer_texcoord[0] = texcoord2f; if (lightcubemap) @@ -1281,7 +1287,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[1] = varray_texcoord3f[1]; R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight); } - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2); @@ -1300,13 +1306,14 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element { // 2/2 3D combine path (original Radeon) memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[0] = GL_REPLACE; m.texcombinergb[1] = GL_DOT3_RGBA_ARB; m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); GL_BlendFunc(GL_ONE, GL_ZERO); R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin); @@ -1315,11 +1322,12 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(basetexture); m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture); m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltoattenuationxyz); @@ -1339,6 +1347,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element { // 4/2 2D combine path (Geforce3, Radeon 8500) memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[0] = GL_REPLACE; @@ -1349,7 +1358,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[1] = varray_texcoord3f[1]; m.pointer_texcoord[2] = varray_texcoord2f[2]; m.pointer_texcoord[3] = varray_texcoord2f[3]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); GL_BlendFunc(GL_ONE, GL_ZERO); R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin); @@ -1360,6 +1369,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(basetexture); m.pointer_texcoord[0] = texcoord2f; if (lightcubemap) @@ -1368,7 +1378,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[1] = varray_texcoord3f[1]; R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight); } - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2); @@ -1387,11 +1397,12 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element { // 2/2/2 2D combine path (any dot3 card) memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture); m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture); m.pointer_texcoord[0] = varray_texcoord2f[0]; m.pointer_texcoord[1] = varray_texcoord2f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); GL_BlendFunc(GL_ONE, GL_ZERO); R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[0], numverts, vertex3f, matrix_modeltoattenuationxyz); @@ -1401,13 +1412,14 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[0] = GL_REPLACE; m.texcombinergb[1] = GL_DOT3_RGBA_ARB; m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_DST_ALPHA, GL_ZERO); R_Shadow_GenTexCoords_Diffuse_NormalCubeMap(varray_texcoord3f[1], numverts, vertex3f, svector3f, tvector3f, normal3f, relativelightorigin); R_Mesh_Draw(numverts, numtriangles, elements); @@ -1415,6 +1427,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(basetexture); m.pointer_texcoord[0] = texcoord2f; if (lightcubemap) @@ -1423,7 +1436,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[1] = varray_texcoord3f[1]; R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight); } - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2); @@ -1447,6 +1460,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element GL_ColorPointer(varray_color4f); VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2); memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(basetexture); m.pointer_texcoord[0] = texcoord2f; if (r_textureunits.integer >= 2) @@ -1456,7 +1470,7 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element m.pointer_texcoord[1] = varray_texcoord2f[1]; R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[1], numverts, vertex3f, matrix_modeltoattenuationxyz); } - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); for (renders = 0;renders < 64 && (color2[0] > 0 || color2[1] > 0 || color2[2] > 0);renders++, color2[0]--, color2[1]--, color2[2]--) { color[0] = bound(0, color2[0], 1); @@ -1489,19 +1503,19 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen bumptexture = r_shadow_blankbumptexture; if (glosstexture == r_shadow_blankglosstexture) colorscale *= r_shadow_gloss2intensity.value; - GL_VertexPointer(vertex3f); GL_ColorPointer(NULL); GL_Color(1,1,1,1); if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && lightcubemap /*&& gl_support_blendsquare*/) // FIXME: detect blendsquare! { // 2/0/0/1/2 3D combine blendsquare path memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); // this squares the result GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO); @@ -1511,7 +1525,8 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = vertex3f; + R_Mesh_State(&m); // square alpha in framebuffer a few times to make it shiny GL_BlendFunc(GL_ZERO, GL_DST_ALPHA); // these comments are a test run through this math for intensity 0.5 @@ -1526,9 +1541,10 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex3d[0] = R_GetTexture(r_shadow_attenuation3dtexture); m.pointer_texcoord[0] = varray_texcoord3f[0]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_DST_ALPHA, GL_ZERO); R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[0], numverts, vertex3f, matrix_modeltoattenuationxyz); R_Mesh_Draw(numverts, numtriangles, elements); @@ -1536,6 +1552,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(glosstexture); if (lightcubemap) { @@ -1544,7 +1561,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight); } m.pointer_texcoord[0] = texcoord2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); VectorScale(lightcolor, colorscale, color2); @@ -1563,12 +1580,13 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen { // 2/0/0/2 3D combine blendsquare path memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); // this squares the result GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO); @@ -1578,7 +1596,8 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = vertex3f; + R_Mesh_State(&m); // square alpha in framebuffer a few times to make it shiny GL_BlendFunc(GL_ZERO, GL_DST_ALPHA); // these comments are a test run through this math for intensity 0.5 @@ -1593,11 +1612,12 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(glosstexture); m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture); m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltoattenuationxyz); @@ -1617,12 +1637,13 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen { // 2/0/0/2/2 2D combine blendsquare path memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(bumptexture); m.texcubemap[1] = R_GetTexture(r_shadow_normalcubetexture); m.texcombinergb[1] = GL_DOT3_RGBA_ARB; m.pointer_texcoord[0] = texcoord2f; m.pointer_texcoord[1] = varray_texcoord3f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(0,0,0,1); // this squares the result GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO); @@ -1632,7 +1653,8 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + m.pointer_vertex = vertex3f; + R_Mesh_State(&m); // square alpha in framebuffer a few times to make it shiny GL_BlendFunc(GL_ZERO, GL_DST_ALPHA); // these comments are a test run through this math for intensity 0.5 @@ -1647,11 +1669,12 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(r_shadow_attenuation2dtexture); m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture); m.pointer_texcoord[0] = varray_texcoord2f[0]; m.pointer_texcoord[1] = varray_texcoord2f[1]; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_DST_ALPHA, GL_ZERO); R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[0], numverts, vertex3f, matrix_modeltoattenuationxyz); R_Shadow_Transform_Vertex3f_TexCoord2f(varray_texcoord2f[1], numverts, vertex3f, matrix_modeltoattenuationz); @@ -1660,6 +1683,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen c_rt_lighttris += numtriangles; memset(&m, 0, sizeof(m)); + m.pointer_vertex = vertex3f; m.tex[0] = R_GetTexture(glosstexture); if (lightcubemap) { @@ -1668,7 +1692,7 @@ void R_Shadow_SpecularLighting(int numverts, int numtriangles, const int *elemen R_Shadow_Transform_Vertex3f_TexCoord3f(varray_texcoord3f[1], numverts, vertex3f, matrix_modeltolight); } m.pointer_texcoord[0] = texcoord2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_ColorMask(1,1,1,0); GL_BlendFunc(GL_DST_ALPHA, GL_ONE); VectorScale(lightcolor, colorscale, color2); @@ -2074,14 +2098,14 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes) qglDisable(GL_STENCIL_TEST); //qglDisable(GL_CULL_FACE); GL_ColorMask(1,1,1,1); - memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); GL_ColorPointer(NULL); GL_Color(0,0.1,0,1); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); + memset(&m, 0, sizeof(m)); for (mesh = rtlight->static_meshchain_shadow;mesh;mesh = mesh->next) { - GL_VertexPointer(mesh->vertex3f); + m.pointer_vertex = mesh->vertex3f; + R_Mesh_State(&m); R_Mesh_Draw_ShowTris(mesh->numverts, mesh->numtriangles, mesh->element3i); } //qglEnable(GL_CULL_FACE); @@ -2132,13 +2156,13 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes) qglDisable(GL_STENCIL_TEST); //qglDisable(GL_CULL_FACE); memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); GL_ColorPointer(NULL); GL_Color(0.2,0,0,1); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); for (mesh = rtlight->static_meshchain_light;mesh;mesh = mesh->next) { - GL_VertexPointer(mesh->vertex3f); + m.pointer_vertex = mesh->vertex3f; + R_Mesh_State(&m); R_Mesh_Draw_ShowTris(mesh->numverts, mesh->numtriangles, mesh->element3i); } //qglEnable(GL_CULL_FACE); @@ -2186,7 +2210,7 @@ void R_ShadowVolumeLighting(int visiblevolumes) if (visiblevolumes) { memset(&m, 0, sizeof(m)); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); GL_BlendFunc(GL_ONE, GL_ONE); GL_DepthMask(false); diff --git a/r_sky.c b/r_sky.c index 0fe747a2..8f0b753d 100644 --- a/r_sky.c +++ b/r_sky.c @@ -237,12 +237,12 @@ static void R_SkyBox(void) GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(true); GL_DepthTest(false); // don't modify or read zbuffer - GL_VertexPointer(skyboxvertex3f); + m.pointer_vertex = skyboxvertex3f; m.pointer_texcoord[0] = skyboxtexcoord2f; for (i = 0;i < 6;i++) { m.tex[0] = R_GetTexture(skyboxside[i]); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(6*4, 2, skyboxelements + i * 6); } } @@ -327,13 +327,13 @@ static void R_SkySphere(void) Matrix4x4_CreateTranslate(&scroll2matrix, speedscale * 2, speedscale * 2, 0); Matrix4x4_CreateIdentity(&identitymatrix); - GL_VertexPointer(skysphere_vertex3f); GL_ColorPointer(NULL); GL_Color(1, 1, 1, 1); GL_BlendFunc(GL_ONE, GL_ZERO); GL_DepthMask(true); GL_DepthTest(false); // don't modify or read zbuffer memset(&m, 0, sizeof(m)); + m.pointer_vertex = skysphere_vertex3f; m.tex[0] = R_GetTexture(solidskytexture); m.pointer_texcoord[0] = skysphere_texcoord2f; R_Mesh_TextureMatrix(0, &scroll1matrix); @@ -343,7 +343,7 @@ static void R_SkySphere(void) m.tex[1] = R_GetTexture(alphaskytexture); m.texcombinergb[1] = gl_combine.integer ? GL_INTERPOLATE_ARB : GL_DECAL; m.pointer_texcoord[1] = skysphere_texcoord2f; - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_TextureMatrix(1, &scroll2matrix); R_Mesh_Draw(skysphere_numverts, skysphere_numtriangles, skysphere_element3i); R_Mesh_TextureMatrix(1, &identitymatrix); @@ -351,12 +351,12 @@ static void R_SkySphere(void) else { // two pass - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_Draw(skysphere_numverts, skysphere_numtriangles, skysphere_element3i); GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); m.tex[0] = R_GetTexture(alphaskytexture); - R_Mesh_State_Texture(&m); + R_Mesh_State(&m); R_Mesh_TextureMatrix(0, &scroll2matrix); R_Mesh_Draw(skysphere_numverts, skysphere_numtriangles, skysphere_element3i); } -- 2.39.2