- fog = 0;
- if (fogenabled)
- {
- texfog = &particletexture[texnum][1];
- VectorSubtract(org, r_origin, fogvec);
- fog = exp(fogdensity/DotProduct(fogvec,fogvec));
- if (fog >= (1.0f / 64.0f))
- {
- if (fog >= (1.0f - (1.0f / 64.0f)))
- {
- // fully fogged, just use the fog texture and render as alpha
- m.cr = fogcolor[0];
- m.cg = fogcolor[1];
- m.cb = fogcolor[2];
- tvst[0][0] = texfog->s1;
- tvst[0][1] = texfog->t1;
- tvst[1][0] = texfog->s1;
- tvst[1][1] = texfog->t2;
- tvst[2][0] = texfog->s2;
- tvst[2][1] = texfog->t2;
- tvst[3][0] = texfog->s2;
- tvst[3][1] = texfog->t1;
- R_Mesh_Draw(&m);
- }
- else
- {
- // partially fogged, darken the first pass
- ifog = 1 - fog;
- m.cr *= ifog;
- m.cg *= ifog;
- m.cb *= ifog;
- if (tex->s1 == texfog->s1 && tex->t1 == texfog->t1)
- {
- // fog texture is the same as the base, just change the color
- m.cr += fogcolor[0] * fog;
- m.cg += fogcolor[1] * fog;
- m.cb += fogcolor[2] * fog;
- R_Mesh_Draw(&m);
- }
- else
- {
- // render the first pass (alpha), then do additive fog
- R_Mesh_Draw(&m);
-
- m.blendfunc2 = GL_ONE;
- m.cr = fogcolor[0] * fog;
- m.cg = fogcolor[1] * fog;
- m.cb = fogcolor[2] * fog;
- tvst[0][0] = texfog->s1;
- tvst[0][1] = texfog->t1;
- tvst[1][0] = texfog->s1;
- tvst[1][1] = texfog->t2;
- tvst[2][0] = texfog->s2;
- tvst[2][1] = texfog->t2;
- tvst[3][0] = texfog->s2;
- tvst[3][1] = texfog->t1;
- R_Mesh_Draw(&m);
- }
- }
- }
- else
- R_Mesh_Draw(&m);
- }
- else
- R_Mesh_Draw(&m);
+ m.numtriangles = 2;
+ m.numverts = 4;
+ m.tex[0] = R_GetTexture(particlefonttexture);
+ if (R_Mesh_Draw_GetBuffer(&m))
+ {
+ m.index[0] = 0;
+ m.index[1] = 1;
+ m.index[2] = 2;
+ m.index[3] = 0;
+ m.index[4] = 2;
+ m.index[5] = 3;
+ m.vertex[0] = org[0] - right[0] - up[0];
+ m.vertex[1] = org[1] - right[1] - up[1];
+ m.vertex[2] = org[2] - right[2] - up[2];
+ m.vertex[4] = org[0] - right[0] + up[0];
+ m.vertex[5] = org[1] - right[1] + up[1];
+ m.vertex[6] = org[2] - right[2] + up[2];
+ m.vertex[8] = org[0] + right[0] + up[0];
+ m.vertex[9] = org[1] + right[1] + up[1];
+ m.vertex[10] = org[2] + right[2] + up[2];
+ m.vertex[12] = org[0] + right[0] - up[0];
+ m.vertex[13] = org[1] + right[1] - up[1];
+ m.vertex[14] = org[2] + right[2] - up[2];
+ m.texcoords[0][0] = tex->s1;
+ m.texcoords[0][1] = tex->t1;
+ m.texcoords[0][2] = tex->s1;
+ m.texcoords[0][3] = tex->t2;
+ m.texcoords[0][4] = tex->s2;
+ m.texcoords[0][5] = tex->t2;
+ m.texcoords[0][6] = tex->s2;
+ m.texcoords[0][7] = tex->t1;
+ m.color[0] = m.color[4] = m.color[8] = m.color[12] = cr * m.colorscale;
+ m.color[1] = m.color[5] = m.color[9] = m.color[13] = cg * m.colorscale;
+ m.color[2] = m.color[6] = m.color[10] = m.color[14] = cb * m.colorscale;
+ m.color[3] = m.color[7] = m.color[11] = m.color[15] = ca;