]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
gl backend now has functions for color array and flat color states (GL_UseColorArray...
[xonotic/darkplaces.git] / gl_rsurf.c
index 864d4d3b65c481a0d0d08d8312802d59436c5609..314429c0f92a7dd49c9897baf9e6064b1c293852 100644 (file)
@@ -245,7 +245,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf, int d
 
                // update cached lighting info
                surf->cached_dlight = 0;
-               surf->cached_lightscalebit = lightscalebit;
+               surf->cached_lightmapscalebit = r_lightmapscalebit;
                surf->cached_ambient = r_ambient.value;
                surf->cached_light[0] = d_lightstylevalue[surf->styles[0]];
                surf->cached_light[1] = d_lightstylevalue[surf->styles[1]];
@@ -300,7 +300,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf, int d
                bl = intblocklights;
                out = templight;
                // deal with lightmap brightness scale
-               shift = 7 + lightscalebit + 8;
+               shift = 7 + r_lightmapscalebit + 8;
                if (ent->model->lightmaprgba)
                {
                        stride = (surf->lightmaptexturestride - smax) * 4;
@@ -339,7 +339,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf, int d
 
                // update cached lighting info
                surf->cached_dlight = 0;
-               surf->cached_lightscalebit = lightscalebit;
+               surf->cached_lightmapscalebit = r_lightmapscalebit;
                surf->cached_ambient = r_ambient.value;
                surf->cached_light[0] = d_lightstylevalue[surf->styles[0]];
                surf->cached_light[1] = d_lightstylevalue[surf->styles[1]];
@@ -390,7 +390,7 @@ static void R_BuildLightMap (const entity_render_t *ent, msurface_t *surf, int d
                bl = floatblocklights;
                out = templight;
                // deal with lightmap brightness scale
-               scale = 1.0f / (1 << (7 + lightscalebit + 8));
+               scale = 1.0f / (1 << (7 + r_lightmapscalebit + 8));
                if (ent->model->lightmaprgba)
                {
                        stride = (surf->lightmaptexturestride - smax) * 4;
@@ -783,7 +783,6 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture
                m.blendfunc1 = GL_ONE;
                m.blendfunc2 = GL_ZERO;
        }
-       m.wantoverbright = false;
        m.depthwrite = true;
        R_Mesh_State(&m);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
@@ -792,10 +791,7 @@ static void RSurfShader_Sky(const entity_render_t *ent, const texture_t *texture
                {
                        R_Mesh_ResizeCheck(mesh->numverts);
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
-                       if (skyrendermasked)
-                               memset(varray_color, 0, mesh->numverts * sizeof(float[4]));
-                       else
-                               R_FillColors(varray_color, mesh->numverts, fogcolor[0] * mesh_colorscale, fogcolor[1] * mesh_colorscale, fogcolor[2] * mesh_colorscale, 1);
+                       GL_Color(fogcolor[0] * r_colorscale, fogcolor[1] * r_colorscale, fogcolor[2] * r_colorscale, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -805,7 +801,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
 {
        const entity_render_t *ent = calldata1;
        const msurface_t *surf = ent->model->surfaces + calldata2;
-       float f;
+       float f, colorscale;
        const surfmesh_t *mesh;
        rmeshstate_t m;
        float alpha = ent->alpha * (surf->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value);
@@ -830,9 +826,15 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                m.blendfunc1 = GL_ONE;
                m.blendfunc2 = GL_ZERO;
        }
-       m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
+       colorscale = r_colorscale;
+       if (gl_combine.integer)
+       {
+               m.texrgbscale[0] = 4;
+               colorscale *= 0.25f;
+       }
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
                R_Mesh_ResizeCheck(mesh->numverts);
@@ -847,7 +849,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                        if (surf->flags & SURF_LIGHTMAP)
                                RSurf_AddLightmapToVertexColors(mesh->lightmapoffsets, varray_color, mesh->numverts, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
                }
-               RSurf_FogColors(varray_vertex, varray_color, mesh_colorscale, mesh->numverts, modelorg);
+               RSurf_FogColors(varray_vertex, varray_color, colorscale, mesh->numverts, modelorg);
                R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
        }
 
@@ -856,7 +858,6 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                memset(&m, 0, sizeof(m));
                m.blendfunc1 = GL_SRC_ALPHA;
                m.blendfunc2 = GL_ONE;
-               m.wantoverbright = false;
                m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
                R_Mesh_State(&m);
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
@@ -865,7 +866,7 @@ static void RSurfShader_Water_Callback(const void *calldata1, int calldata2)
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        if (m.tex[0])
                                memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-                       RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], alpha, mesh_colorscale, mesh->numverts, modelorg);
+                       RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], alpha, r_colorscale, mesh->numverts, modelorg);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -890,7 +891,7 @@ static void RSurfShader_Water(const entity_render_t *ent, const texture_t *textu
 
 static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const msurface_t *surf)
 {
-       float base;
+       float base, colorscale;
        const surfmesh_t *mesh;
        rmeshstate_t m;
        float modelorg[3];
@@ -911,10 +912,16 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m
                m.blendfunc1 = GL_ONE;
                m.blendfunc2 = GL_ZERO;
        }
-       m.wantoverbright = true;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
+       colorscale = r_colorscale;
+       if (gl_combine.integer)
+       {
+               m.texrgbscale[0] = 4;
+               colorscale *= 0.25f;
+       }
        base = ent->effects & EF_FULLBRIGHT ? 2.0f : r_ambient.value * (1.0f / 64.0f);
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
                R_Mesh_ResizeCheck(mesh->numverts);
@@ -928,7 +935,7 @@ static void RSurfShader_Wall_Pass_BaseVertex(const entity_render_t *ent, const m
                        if (surf->flags & SURF_LIGHTMAP)
                                RSurf_AddLightmapToVertexColors(mesh->lightmapoffsets, varray_color, mesh->numverts, surf->samples, ((surf->extents[0]>>4)+1)*((surf->extents[1]>>4)+1)*3, surf->styles);
                }
-               RSurf_FogColors(varray_vertex, varray_color, mesh_colorscale, mesh->numverts, modelorg);
+               RSurf_FogColors(varray_vertex, varray_color, colorscale, mesh->numverts, modelorg);
                R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
        }
 }
@@ -955,15 +962,15 @@ static void RSurfShader_Wall_Pass_BaseFullbright(const entity_render_t *ent, con
                m.blendfunc1 = GL_ONE;
                m.blendfunc2 = GL_ZERO;
        }
-       m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->texture);
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
                R_Mesh_ResizeCheck(mesh->numverts);
                memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-               RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
+               RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, r_colorscale, mesh->numverts, modelorg);
                R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
        }
 }
@@ -977,15 +984,15 @@ static void RSurfShader_Wall_Pass_Glow(const entity_render_t *ent, const msurfac
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE;
-       m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
                R_Mesh_ResizeCheck(mesh->numverts);
                memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-               RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
+               RSurf_FoggedColors(varray_vertex, varray_color, 1, 1, 1, ent->alpha, r_colorscale, mesh->numverts, modelorg);
                R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
        }
 }
@@ -999,16 +1006,16 @@ static void RSurfShader_Wall_Pass_Fog(const entity_render_t *ent, const msurface
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE;
-       m.wantoverbright = false;
        m.tex[0] = R_GetTexture(surf->currenttexture->fogtexture);
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (mesh = surf->mesh;mesh;mesh = mesh->chain)
        {
                R_Mesh_ResizeCheck(mesh->numverts);
                memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                if (m.tex[0])
                        memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-               RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha, mesh_colorscale, mesh->numverts, modelorg);
+               RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], ent->alpha, r_colorscale, mesh->numverts, modelorg);
                R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
        }
 }
@@ -1023,7 +1030,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_ONE;
        m.blendfunc2 = GL_ZERO;
-       //m.wantoverbright = false;
        m.tex[0] = R_GetTexture(texture->texture);
        m.tex[1] = R_GetTexture(texture->surfacechain->lightmaptexture);
        m.tex[2] = R_GetTexture(texture->detailtexture);
@@ -1031,6 +1037,8 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
        m.texrgbscale[1] = 4;
        m.texrgbscale[2] = 2;
        R_Mesh_State(&m);
+       cl = (float) (1 << r_lightmapscalebit) * r_colorscale;
+       GL_Color(cl, cl, cl, 1);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
@@ -1046,8 +1054,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseTripleTexCombine(const entity_render
                        memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
                        memcpy(varray_texcoord[1], mesh->uv, mesh->numverts * sizeof(float[2]));
                        memcpy(varray_texcoord[2], mesh->ab, mesh->numverts * sizeof(float[2]));
-                       cl = (float) (1 << lightscalebit) * mesh_colorscale;
-                       R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1059,14 +1065,15 @@ static void RSurfShader_OpaqueWall_Pass_BaseDoubleTex(const entity_render_t *ent
        const surfmesh_t *mesh;
        rmeshstate_t m;
        int lightmaptexturenum;
-       float cl;
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_ONE;
        m.blendfunc2 = GL_ZERO;
-       m.wantoverbright = true;
        m.tex[0] = R_GetTexture(texture->texture);
        m.tex[1] = R_GetTexture(texture->surfacechain->lightmaptexture);
+       if (gl_combine.integer)
+               m.texrgbscale[1] = 4;
        R_Mesh_State(&m);
+       GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
@@ -1081,8 +1088,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseDoubleTex(const entity_render_t *ent
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
                        memcpy(varray_texcoord[1], mesh->uv, mesh->numverts * sizeof(float[2]));
-                       cl = (float) (1 << lightscalebit) * mesh_colorscale;
-                       R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1096,9 +1101,9 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent,
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_ONE;
        m.blendfunc2 = GL_ZERO;
-       //m.wantoverbright = false;
        m.tex[0] = R_GetTexture(texture->texture);
        R_Mesh_State(&m);
+       GL_Color(1, 1, 1, 1);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
@@ -1106,7 +1111,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseTexture(const entity_render_t *ent,
                        R_Mesh_ResizeCheck(mesh->numverts);
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-                       R_FillColors(varray_color, mesh->numverts, 1, 1, 1, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1118,13 +1122,14 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent,
        const surfmesh_t *mesh;
        rmeshstate_t m;
        int lightmaptexturenum;
-       float cl;
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_ZERO;
        m.blendfunc2 = GL_SRC_COLOR;
-       m.wantoverbright = true;
        m.tex[0] = R_GetTexture(texture->surfacechain->lightmaptexture);
+       if (gl_combine.integer)
+               m.texrgbscale[0] = 4;
        R_Mesh_State(&m);
+       GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                lightmaptexturenum = R_GetTexture(surf->lightmaptexture);
@@ -1138,8 +1143,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseLightmap(const entity_render_t *ent,
                        R_Mesh_ResizeCheck(mesh->numverts);
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        memcpy(varray_texcoord[0], mesh->uv, mesh->numverts * sizeof(float[2]));
-                       cl = (float) (1 << lightscalebit) * mesh_colorscale;
-                       R_FillColors(varray_color, mesh->numverts, cl, cl, cl, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1149,14 +1152,21 @@ static void RSurfShader_OpaqueWall_Pass_Light(const entity_render_t *ent, const
 {
        const msurface_t *surf;
        const surfmesh_t *mesh;
+       float colorscale;
        rmeshstate_t m;
 
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE;
-       m.wantoverbright = true;
        m.tex[0] = R_GetTexture(texture->texture);
+       colorscale = r_colorscale;
+       if (gl_combine.integer)
+       {
+               m.texrgbscale[0] = 4;
+               colorscale *= 0.25f;
+       }
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                if (surf->dlightframe == r_framecount)
@@ -1170,7 +1180,7 @@ static void RSurfShader_OpaqueWall_Pass_Light(const entity_render_t *ent, const
                                        memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
                                        R_FillColors(varray_color, mesh->numverts, 0, 0, 0, 1);
                                        RSurf_LightSeparate(&ent->inversematrix, surf->dlightbits, mesh->numverts, varray_vertex, varray_color);
-                                       RSurf_ScaleColors(varray_color, mesh_colorscale, mesh->numverts);
+                                       RSurf_ScaleColors(varray_color, colorscale, mesh->numverts);
                                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                                }
                        }
@@ -1188,9 +1198,8 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const te
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       //m.wantoverbright = false;
-       //m.tex[0] = 0;
        R_Mesh_State(&m);
+       GL_UseColorArray();
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
@@ -1199,7 +1208,7 @@ static void RSurfShader_OpaqueWall_Pass_Fog(const entity_render_t *ent, const te
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        if (m.tex[0])
                                memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-                       RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], 1, mesh_colorscale, mesh->numverts, modelorg);
+                       RSurf_FogPassColors(varray_vertex, varray_color, fogcolor[0], fogcolor[1], fogcolor[2], 1, r_colorscale, mesh->numverts, modelorg);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1213,9 +1222,9 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_DST_COLOR;
        m.blendfunc2 = GL_SRC_COLOR;
-       //m.wantoverbright = false;
        m.tex[0] = R_GetTexture(texture->detailtexture);
        R_Mesh_State(&m);
+       GL_Color(1, 1, 1, 1);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
@@ -1223,7 +1232,6 @@ static void RSurfShader_OpaqueWall_Pass_BaseDetail(const entity_render_t *ent, c
                        R_Mesh_ResizeCheck(mesh->numverts);
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        memcpy(varray_texcoord[0], mesh->ab, mesh->numverts * sizeof(float[2]));
-                       R_FillColors(varray_color, mesh->numverts, 1, 1, 1, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1237,9 +1245,9 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const t
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE;
-       //m.wantoverbright = false;
        m.tex[0] = R_GetTexture(texture->glowtexture);
        R_Mesh_State(&m);
+       GL_Color(r_colorscale, r_colorscale, r_colorscale, 1);
        for (surf = texture->surfacechain;surf;surf = surf->texturechain)
        {
                for (mesh = surf->mesh;mesh;mesh = mesh->chain)
@@ -1247,7 +1255,6 @@ static void RSurfShader_OpaqueWall_Pass_Glow(const entity_render_t *ent, const t
                        R_Mesh_ResizeCheck(mesh->numverts);
                        memcpy(varray_vertex, mesh->verts, mesh->numverts * sizeof(float[4]));
                        memcpy(varray_texcoord[0], mesh->st, mesh->numverts * sizeof(float[2]));
-                       R_FillColors(varray_color, mesh->numverts, mesh_colorscale, mesh_colorscale, mesh_colorscale, 1);
                        R_Mesh_Draw(mesh->numverts, mesh->numtriangles, mesh->index);
                }
        }
@@ -1439,7 +1446,7 @@ void R_DrawSurfaces(entity_render_t *ent, int sky, int normal)
                                {
                                        if (surf->cached_dlight
                                        || surf->cached_ambient != r_ambient.value
-                                       || surf->cached_lightscalebit != lightscalebit)
+                                       || surf->cached_lightmapscalebit != r_lightmapscalebit)
                                                R_BuildLightMap(ent, surf, false); // base lighting changed
                                        else if (r_dynamic.integer)
                                        {
@@ -1477,16 +1484,14 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2)
        memset(&m, 0, sizeof(m));
        m.blendfunc1 = GL_SRC_ALPHA;
        m.blendfunc2 = GL_ONE_MINUS_SRC_ALPHA;
-       //m.wantoverbright = false;
        R_Mesh_Matrix(&ent->matrix);
        R_Mesh_State(&m);
        R_Mesh_ResizeCheck(portal->numpoints);
        i = portal - ent->model->portals;
-       R_FillColors(varray_color, portal->numpoints,
-               ((i & 0x0007) >> 0) * (1.0f / 7.0f) * mesh_colorscale,
-               ((i & 0x0038) >> 3) * (1.0f / 7.0f) * mesh_colorscale,
-               ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * mesh_colorscale,
-               0.125f);
+       GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_colorscale,
+                        ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_colorscale,
+                        ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_colorscale,
+                        0.125f);
        if (PlaneDiff(r_origin, (&portal->plane)) > 0)
        {
                for (i = portal->numpoints - 1, v = varray_vertex;i >= 0;i--, v += 4)