merged CL_ColorPointer into R_Mesh_State
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 10 Mar 2004 09:48:53 +0000 (09:48 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 10 Mar 2004 09:48:53 +0000 (09:48 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4003 d7cf8633-e32d-0410-b094-e92efae38249

cl_particles.c
gl_backend.c
gl_backend.h
gl_draw.c
gl_models.c
gl_rmain.c
gl_rsurf.c
r_explosion.c
r_lightning.c
r_shadow.c
r_sky.c

index 358d96e..1a6ae07 100644 (file)
@@ -1877,9 +1877,6 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
                }
        }
 
-       GL_ColorPointer(NULL);
-       GL_Color(cr, cg, cb, ca);
-
        R_Mesh_Matrix(&r_identitymatrix);
 
        memset(&m, 0, sizeof(m));
@@ -1888,6 +1885,8 @@ void R_DrawParticleCallback(const void *calldata1, int calldata2)
        m.pointer_vertex = particle_vertex3f;
        R_Mesh_State(&m);
 
+       GL_Color(cr, cg, cb, ca);
+
        if (p->blendmode == 0)
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        else if (p->blendmode == 1)
index aae2f1d..e598d0f 100644 (file)
@@ -451,7 +451,6 @@ void GL_Backend_ResetState(void)
        qglColorPointer(4, GL_FLOAT, sizeof(float[4]), NULL);CHECKGLERROR
        qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
 
-       GL_ColorPointer(NULL);
        GL_Color(0, 0, 0, 0);
        GL_Color(1, 1, 1, 1);
 
@@ -561,32 +560,6 @@ void GL_ColorMask(int r, int g, int b, int a)
        }
 }
 
-void GL_ColorPointer(const float *p)
-{
-       if (gl_state.pointer_color != p)
-       {
-               if (r_showtrispass)
-                       return;
-               CHECKGLERROR
-               if (!gl_state.pointer_color)
-               {
-                       qglEnableClientState(GL_COLOR_ARRAY);
-                       CHECKGLERROR
-               }
-               else if (!p)
-               {
-                       qglDisableClientState(GL_COLOR_ARRAY);
-                       CHECKGLERROR
-                       // when color array is on the glColor gets trashed, set it again
-                       qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);
-                       CHECKGLERROR
-               }
-               gl_state.pointer_color = p;
-               qglColorPointer(4, GL_FLOAT, sizeof(float[4]), gl_state.pointer_color);
-               CHECKGLERROR
-       }
-}
-
 void GL_Color(float cr, float cg, float cb, float ca)
 {
        if (gl_state.pointer_color || gl_state.color4f[0] != cr || gl_state.color4f[1] != cg || gl_state.color4f[2] != cb || gl_state.color4f[3] != ca)
@@ -913,14 +886,36 @@ void R_Mesh_State(const rmeshstate_t *m)
                CHECKGLERROR
        }
 
+       if (r_showtrispass)
+               return;
+
+       if (gl_state.pointer_color != m->pointer_color)
+       {
+               CHECKGLERROR
+               if (!gl_state.pointer_color)
+               {
+                       qglEnableClientState(GL_COLOR_ARRAY);
+                       CHECKGLERROR
+               }
+               else if (!m->pointer_color)
+               {
+                       qglDisableClientState(GL_COLOR_ARRAY);
+                       CHECKGLERROR
+                       // when color array is on the glColor gets trashed, set it again
+                       qglColor4f(gl_state.color4f[0], gl_state.color4f[1], gl_state.color4f[2], gl_state.color4f[3]);
+                       CHECKGLERROR
+               }
+               gl_state.pointer_color = m->pointer_color;
+               qglColorPointer(4, GL_FLOAT, sizeof(float[4]), gl_state.pointer_color);
+               CHECKGLERROR
+       }
+
        if (gl_backend_rebindtextures)
        {
                gl_backend_rebindtextures = false;
                GL_SetupTextureState();
        }
 
-       if (r_showtrispass)
-               return;
        for (i = 0, unit = gl_state.units;i < backendunits;i++, unit++)
        {
                if (unit->t1d != m->tex1d[i])
index 705d292..d5940a3 100644 (file)
@@ -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_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);
 void GL_TransformToScreen(const vec4_t in, vec4_t out);
@@ -52,6 +51,7 @@ typedef struct
 
        // other state set by this
        const float *pointer_vertex;
+       const float *pointer_color;
 }
 rmeshstate_t;
 
index 358c725..13a695f 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -431,7 +431,6 @@ void R_DrawQueue(void)
        pic = NULL;
        texnum = 0;
        color = 0;
-       GL_ColorPointer(NULL);
        GL_Color(1,1,1,1);
 
        batch = false;
@@ -513,12 +512,12 @@ void R_DrawQueue(void)
                case DRAWQUEUE_MESH:
                        mesh = (void *)(dq + 1);
                        m.pointer_vertex = mesh->data_vertex3f;
-                       GL_ColorPointer(mesh->data_color4f);
+                       m.pointer_color = mesh->data_color4f;
                        m.tex[0] = R_GetTexture(mesh->texture);
                        m.pointer_texcoord[0] = mesh->data_texcoord2f;
                        R_Mesh_State(&m);
                        R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
-                       GL_ColorPointer(NULL);
+                       m.pointer_color = NULL;
                        currentpic = "\0";
                        break;
                case DRAWQUEUE_SETCLIP:
index 1205ff2..7f18bcc 100644 (file)
@@ -235,14 +235,12 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2)
                        }
                }
                m.pointer_vertex = varray_vertex3f;
-               R_Mesh_State(&m);
 
                c_alias_polys += mesh->num_triangles;
                R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_VERTEX, varray_vertex3f);
                if (layer->flags & ALIASLAYER_FOG)
                {
                        colorscale *= fog;
-                       GL_ColorPointer(NULL);
                        GL_Color(fogcolor[0] * colorscale, fogcolor[1] * colorscale, fogcolor[2] * colorscale, ent->alpha);
                }
                else
@@ -266,25 +264,20 @@ void R_DrawAliasModelCallback (const void *calldata1, int calldata2)
                                VectorScale(tint, r_shadow_realtime_world_lightmaps.value, tint);
                        colorscale *= ifog;
                        if (fullbright)
-                       {
-                               GL_ColorPointer(NULL);
                                GL_Color(tint[0] * colorscale, tint[1] * colorscale, tint[2] * colorscale, ent->alpha);
-                       }
                        else
                        {
                                if (R_LightModel(ambientcolor4f, diffusecolor, diffusenormal, ent, tint[0] * colorscale, tint[1] * colorscale, tint[2] * colorscale, ent->alpha, false))
                                {
-                                       GL_ColorPointer(varray_color4f);
+                                       m.pointer_color = varray_color4f;
                                        R_Model_Alias_GetMesh_Array3f(ent, mesh, MODELARRAY_NORMAL, varray_normal3f);
                                        R_LightModel_CalcVertexColors(ambientcolor4f, diffusecolor, diffusenormal, mesh->num_vertices, varray_vertex3f, varray_normal3f, varray_color4f);
                                }
                                else
-                               {
-                                       GL_ColorPointer(NULL);
                                        GL_Color(ambientcolor4f[0], ambientcolor4f[1], ambientcolor4f[2], ambientcolor4f[3]);
-                               }
                        }
                }
+               R_Mesh_State(&m);
                R_Mesh_Draw(mesh->num_vertices, mesh->num_triangles, mesh->data_element3i);
        }
 }
@@ -750,7 +743,6 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        mstate.tex[0] = R_GetTexture(texture);
        mstate.pointer_texcoord[0] = ent->model->alias.zymdata_texcoords;
        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);
 
@@ -758,14 +750,12 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
        ZymoticCalcNormal3f(numverts, varray_vertex3f, aliasvert_normal3f, ent->model->alias.zymnum_shaders, ent->model->alias.zymdata_renderlist);
        if (R_LightModel(ambientcolor4f, diffusecolor, diffusenormal, ent, ifog * colorscale, ifog * colorscale, ifog * colorscale, ent->alpha, false))
        {
-               GL_ColorPointer(varray_color4f);
+               mstate.pointer_color = varray_color4f;
                R_LightModel_CalcVertexColors(ambientcolor4f, diffusecolor, diffusenormal, numverts, varray_vertex3f, aliasvert_normal3f, varray_color4f);
        }
        else
-       {
-               GL_ColorPointer(NULL);
                GL_Color(ambientcolor4f[0], ambientcolor4f[1], ambientcolor4f[2], ambientcolor4f[3]);
-       }
+       R_Mesh_State(&mstate);
        R_Mesh_Draw(numverts, numtriangles, elements);
        c_alias_polys += numtriangles;
 
@@ -782,9 +772,9 @@ void R_DrawZymoticModelMeshCallback (const void *calldata1, int calldata2)
                mstate.pointer_vertex = varray_vertex3f;
                R_Mesh_State(&mstate);
 
-               GL_ColorPointer(NULL);
                GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha * fog);
                ZymoticTransformVerts(numverts, varray_vertex3f, ent->model->alias.zymdata_vertbonecounts, ent->model->alias.zymdata_verts);
+               R_Mesh_State(&mstate);
                R_Mesh_Draw(numverts, numtriangles, elements);
                c_alias_polys += numtriangles;
        }
index e0be503..bcaf390 100644 (file)
@@ -564,7 +564,6 @@ static void R_BlendView(void)
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(true);
        GL_DepthTest(false); // magic
-       GL_ColorPointer(NULL);
        GL_Color(r_refdef.viewblend[0], r_refdef.viewblend[1], r_refdef.viewblend[2], r_refdef.viewblend[3]);
        r = 64;
        vertex3f[0] = r_vieworigin[0] + r_viewforward[0] * 1.5 + r_viewleft[0] * r - r_viewup[0] * r;
@@ -764,10 +763,6 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        GL_DepthTest(true);
        R_Mesh_Matrix(&r_identitymatrix);
 
-       memset(&m, 0, sizeof(m));
-       R_Mesh_State(&m);
-
-       R_Mesh_GetSpace(8);
        vertex3f[ 0] = mins[0];vertex3f[ 1] = mins[1];vertex3f[ 2] = mins[2];
        vertex3f[ 3] = maxs[0];vertex3f[ 4] = mins[1];vertex3f[ 5] = mins[2];
        vertex3f[ 6] = mins[0];vertex3f[ 7] = maxs[1];vertex3f[ 8] = mins[2];
@@ -776,7 +771,6 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        vertex3f[15] = maxs[0];vertex3f[16] = mins[1];vertex3f[17] = maxs[2];
        vertex3f[18] = mins[0];vertex3f[19] = maxs[1];vertex3f[20] = maxs[2];
        vertex3f[21] = maxs[0];vertex3f[22] = maxs[1];vertex3f[23] = maxs[2];
-       GL_ColorPointer(color);
        R_FillColors(color, 8, cr, cg, cb, ca);
        if (fogenabled)
        {
@@ -790,6 +784,10 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
                        c[2] = c[2] * f1 + fogcolor[2] * f2;
                }
        }
+       memset(&m, 0, sizeof(m));
+       m.pointer_vertex = vertex3f;
+       m.pointer_color = color;
+       R_Mesh_State(&m);
        R_Mesh_Draw(8, 12);
 }
 */
@@ -837,7 +835,6 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
 
        memset(&m, 0, sizeof(m));
        m.pointer_vertex = nomodelvertex3f;
-       R_Mesh_State(&m);
 
        if (ent->flags & EF_ADDITIVE)
        {
@@ -858,7 +855,7 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
        if (fogenabled)
        {
                memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
-               GL_ColorPointer(color4f);
+               m.pointer_color = color4f;
                VectorSubtract(ent->origin, r_vieworigin, diff);
                f2 = exp(fogdensity/DotProduct(diff, diff));
                f1 = 1 - f2;
@@ -873,12 +870,13 @@ void R_DrawNoModelCallback(const void *calldata1, int calldata2)
        else if (ent->alpha != 1)
        {
                memcpy(color4f, nomodelcolor4f, sizeof(float[6*4]));
-               GL_ColorPointer(color4f);
+               m.pointer_color = color4f;
                for (i = 0, c = color4f;i < 6;i++, c += 4)
                        c[3] *= ent->alpha;
        }
        else
-               GL_ColorPointer(nomodelcolor4f);
+               m.pointer_color = nomodelcolor4f;
+       R_Mesh_State(&m);
        R_Mesh_Draw(6, 8, nomodelelements);
 }
 
@@ -935,18 +933,10 @@ 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_BlendFunc(blendfunc1, blendfunc2);
        GL_DepthMask(false);
        GL_DepthTest(!depthdisable);
 
-       memset(&m, 0, sizeof(m));
-       m.tex[0] = R_GetTexture(texture);
-       m.pointer_texcoord[0] = spritetexcoord2f;
-       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;
        varray_vertex3f[ 2] = origin[2] + left[2] * scalex2 + up[2] * scaley1;
@@ -959,6 +949,13 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, int depth
        varray_vertex3f[ 9] = origin[0] + left[0] * scalex1 + up[0] * scaley1;
        varray_vertex3f[10] = origin[1] + left[1] * scalex1 + up[1] * scaley1;
        varray_vertex3f[11] = origin[2] + left[2] * scalex1 + up[2] * scaley1;
+
+       memset(&m, 0, sizeof(m));
+       m.tex[0] = R_GetTexture(texture);
+       m.pointer_texcoord[0] = spritetexcoord2f;
+       m.pointer_vertex = varray_vertex3f;
+       R_Mesh_State(&m);
+       GL_Color(cr, cg, cb, ca);
        R_Mesh_Draw(4, 2, polygonelements);
 }
 
index 8f9ef9f..976f7e4 100644 (file)
@@ -745,7 +745,6 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture
 
        R_Mesh_Matrix(&ent->matrix);
 
-       GL_ColorPointer(NULL);
        GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], 1);
        if (skyrendermasked)
        {
@@ -763,12 +762,11 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture
        GL_DepthMask(true);
        GL_DepthTest(true);
 
-
+       memset(&m, 0, sizeof(m));
        while((surf = *surfchain++) != NULL)
        {
                if (surf->visframe == r_framecount)
                {
-                       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);
@@ -832,12 +830,9 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                m.tex[0] = R_GetTexture(texture->skin.base);
        GL_DepthTest(true);
        if (fogenabled)
-               GL_ColorPointer(varray_color4f);
+               m.pointer_color = varray_color4f;
        else
-       {
-               GL_ColorPointer(NULL);
                GL_Color(1, 1, 1, alpha);
-       }
        if (gl_textureshader && r_watershader.value && !fogenabled)
        {
                GL_ActiveTexture (0);
@@ -850,16 +845,16 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                qglEnable (GL_TEXTURE_SHADER_NV);
        }
 
-       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(&m);
        if (fogenabled)
        {
                R_FillColors(varray_color4f, surf->mesh.num_vertices, 1, 1, 1, alpha);
                RSurf_FogColors_Vertex3f_Color4f(surf->mesh.data_vertex3f, varray_color4f, 1, surf->mesh.num_vertices, modelorg);
        }
+       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(&m);
        R_Mesh_Draw(surf->mesh.num_vertices, surf->mesh.num_triangles, surf->mesh.data_element3i);
 
        if (gl_textureshader && r_watershader.value && !fogenabled)
@@ -877,7 +872,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                GL_DepthTest(true);
                m.tex[0] = R_GetTexture(texture->skin.fog);
                m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
-               GL_ColorPointer(varray_color4f);
+               m.pointer_color = varray_color4f;
                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);
@@ -944,8 +939,8 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m
        }
        base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
        GL_DepthTest(true);
-       GL_ColorPointer(varray_color4f);
 
+       m.pointer_color = varray_color4f;
        m.pointer_vertex = surf->mesh.data_vertex3f;
        m.pointer_texcoord[0] = surf->mesh.data_texcoordtexture2f;
        R_Mesh_State(&m);
@@ -970,8 +965,8 @@ static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurfac
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(true);
+       m.pointer_color = varray_color4f;
        m.tex[0] = R_GetTexture(texture->skin.glow);
-       GL_ColorPointer(varray_color4f);
 
        m.pointer_vertex = surf->mesh.data_vertex3f;
        if (m.tex[0])
@@ -990,8 +985,8 @@ static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(true);
+       m.pointer_color = varray_color4f;
        m.tex[0] = R_GetTexture(texture->skin.fog);
-       GL_ColorPointer(varray_color4f);
 
        m.pointer_vertex = surf->mesh.data_vertex3f;
        if (m.tex[0])
@@ -1020,7 +1015,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetailGlow(co
                m.tex[3] = R_GetTexture(texture->skin.glow);
                m.texcombinergb[3] = GL_ADD;
        }
-       GL_ColorPointer(NULL);
        if (r_shadow_realtime_world.integer)
                GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
        else
@@ -1057,7 +1051,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmapDetail(const
        m.texrgbscale[1] = 2;
        m.tex[2] = R_GetTexture(texture->skin.detail);
        m.texrgbscale[2] = 2;
-       GL_ColorPointer(NULL);
        if (r_shadow_realtime_world.integer)
                GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
        else
@@ -1091,7 +1084,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseCombine_TextureLightmap(const entity
        m.tex[0] = R_GetTexture(texture->skin.base);
        m.tex[1] = R_GetTexture((**surfchain).lightmaptexture);
        m.texrgbscale[1] = 2;
-       GL_ColorPointer(NULL);
        if (r_shadow_realtime_world.integer)
                GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
        else
@@ -1120,7 +1112,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent,
        GL_DepthTest(true);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        m.tex[0] = R_GetTexture(texture->skin.base);
-       GL_ColorPointer(NULL);
        if (r_shadow_realtime_world.integer)
                GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
        else
@@ -1147,7 +1138,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent,
        GL_DepthMask(false);
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture((**surfchain).lightmaptexture);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        while((surf = *surfchain++) != NULL)
        {
@@ -1173,7 +1163,7 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const te
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       GL_ColorPointer(varray_color4f);
+       m.pointer_color = varray_color4f;
        while((surf = *surfchain++) != NULL)
        {
                if (surf->visframe == r_framecount)
@@ -1197,7 +1187,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c
        GL_DepthMask(false);
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture(texture->skin.detail);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        while((surf = *surfchain++) != NULL)
        {
@@ -1220,7 +1209,6 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const t
        GL_DepthMask(false);
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture(texture->skin.glow);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        while((surf = *surfchain++) != NULL)
        {
@@ -1243,7 +1231,6 @@ static void RSurfShader_OpaqueWall_Pass_OpaqueGlow(const entity_render_t *ent, c
        GL_BlendFunc(GL_SRC_ALPHA, GL_ZERO);
        GL_DepthMask(true);
        m.tex[0] = R_GetTexture(texture->skin.glow);
-       GL_ColorPointer(NULL);
        if (m.tex[0])
                GL_Color(1, 1, 1, 1);
        else
@@ -1271,7 +1258,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmapOnly(const entity_render_t *
        GL_DepthMask(true);
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture((**surfchain).lightmaptexture);
-       GL_ColorPointer(NULL);
        if (r_shadow_realtime_world.integer)
                GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
        else
@@ -1540,7 +1526,6 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2)
        R_Mesh_State(&m);
 
        i = portal - ent->model->brushq1.portals;
-       GL_ColorPointer(NULL);
        GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f),
                         ((i & 0x0038) >> 3) * (1.0f / 7.0f),
                         ((i & 0x01C0) >> 6) * (1.0f / 7.0f),
@@ -2030,7 +2015,6 @@ void R_DrawCollisionBrush(colbrushf_t *brush)
        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);
        R_Mesh_Draw(brush->numpoints, brush->numtriangles, brush->elements);
 }
@@ -2045,7 +2029,6 @@ void R_Q3BSP_DrawCollisionFace(entity_render_t *ent, q3mface_t *face)
        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);
        R_Mesh_Draw(face->num_collisionvertices, face->num_collisiontriangles, face->data_collisionelement3i);
 }
@@ -2065,7 +2048,6 @@ void R_Q3BSP_DrawSkyFace(entity_render_t *ent, q3mface_t *face)
 
        R_Mesh_Matrix(&ent->matrix);
 
-       GL_ColorPointer(NULL);
        GL_Color(fogcolor[0], fogcolor[1], fogcolor[2], 1);
        if (skyrendermasked)
        {
@@ -2098,7 +2080,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_OpaqueGlow(entity_render_t *ent, q3mface_t
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);
        GL_DepthTest(true);
-       GL_ColorPointer(NULL);
        if (face->texture->skin.glow)
        {
                m.tex[0] = R_GetTexture(face->texture->skin.glow);
@@ -2124,7 +2105,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureLightmapCombine(entity_render_t *en
        m.tex[1] = R_GetTexture(face->lightmaptexture);
        m.pointer_texcoord[1] = face->data_texcoordlightmap2f;
        m.texrgbscale[1] = 2;
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
@@ -2140,7 +2120,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_Texture(entity_render_t *ent, q3mface_t *f
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture(face->texture->skin.base);
        m.pointer_texcoord[0] = face->data_texcoordtexture2f;
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
@@ -2156,7 +2135,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_Lightmap(entity_render_t *ent, q3mface_t *
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture(face->lightmaptexture);
        m.pointer_texcoord[0] = face->data_texcoordlightmap2f;
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
@@ -2172,7 +2150,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_LightmapOnly(entity_render_t *ent, q3mface
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture(face->lightmaptexture);
        m.pointer_texcoord[0] = face->data_texcoordlightmap2f;
-       GL_ColorPointer(NULL);
        if (r_shadow_realtime_world.integer)
                GL_Color(r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, r_shadow_realtime_world_lightmaps.value, 1);
        else
@@ -2189,7 +2166,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_Glow(entity_render_t *ent, q3mface_t *face
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       GL_ColorPointer(NULL);
        if (face->texture->skin.glow)
        {
                m.tex[0] = R_GetTexture(face->texture->skin.glow);
@@ -2220,10 +2196,10 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureVertex(entity_render_t *ent, q3mfac
        if (mul == 2 && gl_combine.integer)
        {
                m.texrgbscale[0] = 2;
-               GL_ColorPointer(face->data_color4f);
+               m.pointer_color = face->data_color4f;
        }
        else if (mul == 1)
-               GL_ColorPointer(face->data_color4f);
+               m.pointer_color = face->data_color4f;
        else
        {
                for (i = 0;i < face->num_vertices;i++)
@@ -2233,7 +2209,7 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_TextureVertex(entity_render_t *ent, q3mfac
                        varray_color4f[i*4+2] = face->data_color4f[i*4+2] * mul;
                        varray_color4f[i*4+3] = face->data_color4f[i*4+3];
                }
-               GL_ColorPointer(varray_color4f);
+               m.pointer_color = varray_color4f;
        }
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
@@ -2253,7 +2229,7 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_VertexOnly(entity_render_t *ent, q3mface_t
        if (r_shadow_realtime_world.integer && r_shadow_realtime_world_lightmaps.value != 1)
                mul *= r_shadow_realtime_world_lightmaps.value;
        if (mul == 1)
-               GL_ColorPointer(face->data_color4f);
+               m.pointer_color = face->data_color4f;
        else
        {
                for (i = 0;i < face->num_vertices;i++)
@@ -2263,7 +2239,7 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_VertexOnly(entity_render_t *ent, q3mface_t
                        varray_color4f[i*4+2] = face->data_color4f[i*4+2] * 2.0f;
                        varray_color4f[i*4+3] = face->data_color4f[i*4+3];
                }
-               GL_ColorPointer(varray_color4f);
+               m.pointer_color = varray_color4f;
        }
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
@@ -2279,7 +2255,6 @@ void R_Q3BSP_DrawFace_OpaqueWall_Pass_AddTextureAmbient(entity_render_t *ent, q3
        GL_DepthTest(true);
        m.tex[0] = R_GetTexture(face->texture->skin.base);
        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);
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
@@ -2309,13 +2284,12 @@ void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int facenumber)
                {
                        m.tex[1] = R_GetTexture(face->lightmaptexture);
                        m.pointer_texcoord[1] = face->data_texcoordlightmap2f;
-                       GL_ColorPointer(NULL);
                        GL_Color(1, 1, 1, ent->alpha);
                }
                else
                {
                        if (ent->alpha == 1)
-                               GL_ColorPointer(face->data_color4f);
+                               m.pointer_color = face->data_color4f;
                        else
                        {
                                int i;
@@ -2326,7 +2300,7 @@ void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int facenumber)
                                        varray_color4f[i*4+2] = face->data_color4f[i*4+2];
                                        varray_color4f[i*4+3] = face->data_color4f[i*4+3] * ent->alpha;
                                }
-                               GL_ColorPointer(varray_color4f);
+                               m.pointer_color = varray_color4f;
                        }
                }
        }
@@ -2340,7 +2314,7 @@ void R_Q3BSP_DrawFace_TransparentCallback(const void *voident, int facenumber)
                        varray_color4f[i*4+2] = face->data_color4f[i*4+2] * 2.0f;
                        varray_color4f[i*4+3] = face->data_color4f[i*4+3] * ent->alpha;
                }
-               GL_ColorPointer(varray_color4f);
+               m.pointer_color = varray_color4f;
        }
        m.pointer_vertex = face->data_vertex3f;
        R_Mesh_State(&m);
index 267e092..10b65b8 100644 (file)
@@ -188,8 +188,6 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2)
        numtriangles = EXPLOSIONTRIS;
        numverts = EXPLOSIONVERTS;
        alpha = e->alpha;
-       GL_ColorPointer(NULL);
-       GL_Color(alpha, alpha, alpha, 1);
 
        memset(&m, 0, sizeof(m));
        m.tex[0] = R_GetTexture(explosiontexture);
@@ -197,6 +195,8 @@ void R_DrawExplosionCallback(const void *calldata1, int calldata2)
        m.pointer_vertex = e->vert[0];
        R_Mesh_State(&m);
 
+       GL_Color(alpha, alpha, alpha, 1);
+
        R_Mesh_Draw(numverts, numtriangles, explosiontris[0]);
 }
 
index 5108a73..18207a6 100644 (file)
@@ -282,7 +282,6 @@ void R_DrawLightningBeamCallback(const void *calldata1, int calldata2)
                m.tex[0] = R_GetTexture(r_lightningbeamtexture);
        m.pointer_texcoord[0] = varray_texcoord2f[0];
        m.pointer_vertex = varray_vertex3f;
-       R_Mesh_State(&m);
 
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        GL_DepthMask(false);
@@ -310,15 +309,15 @@ void R_DrawLightningBeamCallback(const void *calldata1, int calldata2)
        if (fogenabled)
        {
                // per vertex colors if fog is used
-               GL_ColorPointer(varray_color4f);
+               m.pointer_color = varray_color4f;
                R_FogLightningBeam_Vertex3f_Color4f(varray_vertex3f, varray_color4f, 12, r_lightningbeam_color_red.value, r_lightningbeam_color_green.value, r_lightningbeam_color_blue.value, 1);
        }
        else
        {
                // solid color if fog is not used
-               GL_ColorPointer(NULL);
                GL_Color(r_lightningbeam_color_red.value, r_lightningbeam_color_green.value, r_lightningbeam_color_blue.value, 1);
        }
+       R_Mesh_State(&m);
 
        // draw the 3 polygons as one batch of 6 triangles using the 12 vertices
        R_Mesh_Draw(12, 6, r_lightningbeamelements);
index 55a8d77..52fb9fe 100644 (file)
@@ -737,7 +737,6 @@ void R_Shadow_Stage_Begin(void)
        GL_DepthMask(false);
        GL_DepthTest(true);
        R_Mesh_State(&m);
-       GL_ColorPointer(NULL);
        GL_Color(0, 0, 0, 1);
        qglCullFace(GL_FRONT); // quake is backwards, this culls back faces
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
@@ -769,7 +768,6 @@ void R_Shadow_Stage_ShadowVolumes(void)
        rmeshstate_t m;
        memset(&m, 0, sizeof(m));
        R_Mesh_State(&m);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(0, 0, 0, 0);
        GL_BlendFunc(GL_ONE, GL_ZERO);
@@ -825,7 +823,6 @@ void R_Shadow_Stage_LightWithoutShadows(void)
        GL_DepthTest(true);
        qglPolygonOffset(0, 0);
        //qglDisable(GL_POLYGON_OFFSET_FILL);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(1, 1, 1, 1);
        qglDepthFunc(GL_EQUAL);
@@ -850,7 +847,6 @@ void R_Shadow_Stage_LightWithShadows(void)
        GL_DepthTest(true);
        qglPolygonOffset(0, 0);
        //qglDisable(GL_POLYGON_OFFSET_FILL);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(1, 1, 1, 1);
        qglDepthFunc(GL_EQUAL);
@@ -877,7 +873,6 @@ void R_Shadow_Stage_End(void)
        GL_DepthTest(true);
        qglPolygonOffset(0, 0);
        //qglDisable(GL_POLYGON_OFFSET_FILL);
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        GL_ColorMask(1, 1, 1, 1);
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
@@ -1194,7 +1189,6 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element
        {
                if (!bumptexture)
                        bumptexture = r_shadow_blankbumptexture;
-               GL_ColorPointer(NULL);
                GL_Color(1,1,1,1);
                // colorscale accounts for how much we multiply the brightness during combine
                // mult is how many times the final pass of the lighting will be
@@ -1457,10 +1451,10 @@ void R_Shadow_DiffuseLighting(int numverts, int numtriangles, const int *element
                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
                GL_DepthMask(false);
                GL_DepthTest(true);
-               GL_ColorPointer(varray_color4f);
                VectorScale(lightcolor, r_shadow_lightintensityscale.value, color2);
                memset(&m, 0, sizeof(m));
                m.pointer_vertex = vertex3f;
+               m.pointer_color = varray_color4f;
                m.tex[0] = R_GetTexture(basetexture);
                m.pointer_texcoord[0] = texcoord2f;
                if (r_textureunits.integer >= 2)
@@ -1503,7 +1497,6 @@ 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_ColorPointer(NULL);
                GL_Color(1,1,1,1);
                if (r_shadow_texture3d.integer && r_textureunits.integer >= 2 && lightcubemap /*&& gl_support_blendsquare*/) // FIXME: detect blendsquare!
                {
@@ -2098,7 +2091,6 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes)
                                qglDisable(GL_STENCIL_TEST);
                                //qglDisable(GL_CULL_FACE);
                                GL_ColorMask(1,1,1,1);
-                               GL_ColorPointer(NULL);
                                GL_Color(0,0.1,0,1);
                                GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
                                memset(&m, 0, sizeof(m));
@@ -2156,7 +2148,6 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes)
                                        qglDisable(GL_STENCIL_TEST);
                                        //qglDisable(GL_CULL_FACE);
                                        memset(&m, 0, sizeof(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)
@@ -2216,7 +2207,6 @@ void R_ShadowVolumeLighting(int visiblevolumes)
                GL_DepthMask(false);
                GL_DepthTest(r_shadow_visiblevolumes.integer < 2);
                qglDisable(GL_CULL_FACE);
-               GL_ColorPointer(NULL);
                GL_Color(0.0, 0.0125, 0.1, 1);
        }
        else
diff --git a/r_sky.c b/r_sky.c
index 8f0b753..110407c 100644 (file)
--- a/r_sky.c
+++ b/r_sky.c
@@ -231,7 +231,6 @@ static void R_SkyBox(void)
 {
        int i;
        rmeshstate_t m;
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        memset(&m, 0, sizeof(m));
        GL_BlendFunc(GL_ONE, GL_ZERO);
@@ -327,7 +326,6 @@ static void R_SkySphere(void)
        Matrix4x4_CreateTranslate(&scroll2matrix, speedscale * 2, speedscale * 2, 0);
        Matrix4x4_CreateIdentity(&identitymatrix);
 
-       GL_ColorPointer(NULL);
        GL_Color(1, 1, 1, 1);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);