+static void RSurfShader_Wall_Pass_Glow(msurface_t *surf)
+{
+ int i;
+ float diff[3], ifog;
+ surfvertex_t *v;
+ surfvert_t *sv;
+ surfmesh_t *mesh;
+ rmeshinfo_t m;
+
+ memset(&m, 0, sizeof(m));
+ if (currentrenderentity->effects & EF_ADDITIVE)
+ m.transparent = true;
+ else if (surf->currenttexture->fogtexture != NULL || currentrenderentity->alpha != 1)
+ m.transparent = true;
+ else
+ m.transparent = false;
+ m.blendfunc1 = GL_SRC_ALPHA;
+ m.blendfunc2 = GL_ONE;
+ m.cr = 1;
+ m.cg = 1;
+ m.cb = 1;
+ m.ca = currentrenderentity->alpha;
+ m.tex[0] = R_GetTexture(surf->currenttexture->glowtexture);
+ m.texcoordstep[0] = sizeof(surfvertex_t);
+ for (mesh = surf->mesh;mesh;mesh = mesh->chain)
+ {
+ m.numtriangles = mesh->numtriangles;
+ m.numverts = mesh->numverts;
+ m.index = mesh->index;
+ m.texcoords[0] = &mesh->vertex->st[0];
+ if (fogenabled)
+ {
+ m.color = &svert[0].c[0];
+ m.colorstep = sizeof(surfvert_t);
+ if (softwaretransform_complexity)
+ {
+ m.vertex = &svert[0].v[0];
+ m.vertexstep = sizeof(surfvert_t);
+ for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
+ {
+ softwaretransform(v->v, sv->v);
+ VectorSubtract(sv->v, r_origin, diff);
+ ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
+ sv->c[0] = m.cr * ifog;
+ sv->c[1] = m.cg * ifog;
+ sv->c[2] = m.cb * ifog;
+ sv->c[3] = m.ca;
+ }
+ }
+ else
+ {
+ m.vertex = &mesh->vertex->v[0];
+ m.vertexstep = sizeof(surfvertex_t);
+ for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
+ {
+ VectorSubtract(v->v, r_origin, diff);
+ ifog = 1 - exp(fogdensity/DotProduct(diff, diff));
+ sv->c[0] = m.cr * ifog;
+ sv->c[1] = m.cg * ifog;
+ sv->c[2] = m.cb * ifog;
+ sv->c[3] = m.ca;
+ }
+ }
+ }
+ else
+ {
+ if (softwaretransform_complexity)
+ {
+ m.vertex = &svert[0].v[0];
+ m.vertexstep = sizeof(surfvert_t);
+ for (i = 0, sv = svert, v = mesh->vertex;i < m.numverts;i++, sv++, v++)
+ softwaretransform(v->v, sv->v);
+ }
+ else
+ {
+ m.vertex = &mesh->vertex->v[0];
+ m.vertexstep = sizeof(surfvertex_t);
+ }
+ }
+ R_Mesh_Draw(&m);
+ }
+}