int texturesurfaceindex;
qboolean applycolor;
qboolean applyfog;
- rmeshstate_t m;
int layerindex;
const texturelayer_t *layer;
RSurf_PrepareVerticesForBatch(true, false, texturenumsurfaces, texturesurfacelist);
switch (layer->type)
{
case TEXTURELAYERTYPE_LITTEXTURE:
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(r_texture_white);
- m.pointer_texcoord[0] = rsurface.modeltexcoordlightmap2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordlightmap2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordlightmap2f_bufferoffset;
- m.tex[1] = R_GetTexture(layer->texture);
- m.texmatrix[1] = layer->texmatrix;
- m.texrgbscale[1] = layertexrgbscale;
- m.pointer_texcoord[1] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[1] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[1] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ // single-pass lightmapped texture with 2x rgbscale
+ R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
+ R_Mesh_TexMatrix(0, NULL);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.modeltexcoordlightmap2f, rsurface.modeltexcoordlightmap2f_bufferobject, rsurface.modeltexcoordlightmap2f_bufferoffset);
+ R_Mesh_TexBind(1, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(1, &layer->texmatrix);
+ R_Mesh_TexCombine(1, GL_MODULATE, GL_MODULATE, layertexrgbscale, 1);
+ R_Mesh_TexCoordPointer(1, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT)
RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
else if (rsurface.uselightmaptexture)
RSurf_DrawBatch_GL11_VertexColor(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
break;
case TEXTURELAYERTYPE_TEXTURE:
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(layer->texture);
- m.texmatrix[0] = layer->texmatrix;
- m.texrgbscale[0] = layertexrgbscale;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ // singletexture unlit texture with transparency support
+ R_Mesh_TexBind(0, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(0, &layer->texmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, layertexrgbscale, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
+ R_Mesh_TexBind(1, 0);
+ R_Mesh_TexCoordPointer(1, 2, NULL, 0, 0);
RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layercolor[0], layercolor[1], layercolor[2], layercolor[3], applycolor, applyfog);
break;
case TEXTURELAYERTYPE_FOG:
- memset(&m, 0, sizeof(m));
- m.texrgbscale[0] = layertexrgbscale;
+ // singletexture fogging
if (layer->texture)
{
- m.tex[0] = R_GetTexture(layer->texture);
- m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
+ R_Mesh_TexBind(0, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(0, &layer->texmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, layertexrgbscale, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
+ }
+ else
+ {
+ R_Mesh_TexBind(0, 0);
+ R_Mesh_TexCoordPointer(0, 2, NULL, 0, 0);
}
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(1, 0);
+ R_Mesh_TexCoordPointer(1, 2, NULL, 0, 0);
// generate a color array for the fog pass
R_Mesh_ColorPointer(rsurface.array_color4f, 0, 0);
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
// OpenGL 1.1 - crusty old voodoo path
int texturesurfaceindex;
qboolean applyfog;
- rmeshstate_t m;
int layerindex;
const texturelayer_t *layer;
RSurf_PrepareVerticesForBatch(true, false, texturenumsurfaces, texturesurfacelist);
{
// two-pass lit texture with 2x rgbscale
// first the lightmap pass
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(r_texture_white);
- m.pointer_texcoord[0] = rsurface.modeltexcoordlightmap2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.modeltexcoordlightmap2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.modeltexcoordlightmap2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(0, R_GetTexture(r_texture_white));
+ R_Mesh_TexMatrix(0, NULL);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.modeltexcoordlightmap2f, rsurface.modeltexcoordlightmap2f_bufferobject, rsurface.modeltexcoordlightmap2f_bufferoffset);
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT)
RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, 1, 1, 1, 1, false, false);
else if (rsurface.uselightmaptexture)
GL_LockArrays(0, 0);
// then apply the texture to it
GL_BlendFunc(GL_DST_COLOR, GL_SRC_COLOR);
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(layer->texture);
- m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(0, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(0, &layer->texmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layer->color[0] * 0.5f, layer->color[1] * 0.5f, layer->color[2] * 0.5f, layer->color[3], layer->color[0] != 2 || layer->color[1] != 2 || layer->color[2] != 2 || layer->color[3] != 1, false);
}
else
{
// single pass vertex-lighting-only texture with 1x rgbscale and transparency support
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(layer->texture);
- m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(0, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(0, &layer->texmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
if (rsurface.texture->currentmaterialflags & MATERIALFLAG_MODELLIGHT)
RSurf_DrawBatch_GL11_VertexShade(texturenumsurfaces, texturesurfacelist, layer->color[0], layer->color[1], layer->color[2], layer->color[3], layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1, applyfog);
else
break;
case TEXTURELAYERTYPE_TEXTURE:
// singletexture unlit texture with transparency support
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(layer->texture);
- m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(0, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(0, &layer->texmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
RSurf_DrawBatch_GL11_Unlit(texturenumsurfaces, texturesurfacelist, layer->color[0], layer->color[1], layer->color[2], layer->color[3], layer->color[0] != 1 || layer->color[1] != 1 || layer->color[2] != 1 || layer->color[3] != 1, applyfog);
break;
case TEXTURELAYERTYPE_FOG:
// singletexture fogging
- R_Mesh_ColorPointer(rsurface.array_color4f, 0, 0);
if (layer->texture)
{
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(layer->texture);
- m.texmatrix[0] = layer->texmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(0, R_GetTexture(layer->texture));
+ R_Mesh_TexMatrix(0, &layer->texmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
}
else
- R_Mesh_ResetTextureState();
+ {
+ R_Mesh_TexBind(0, 0);
+ R_Mesh_TexCoordPointer(0, 2, NULL, 0, 0);
+ }
// generate a color array for the fog pass
+ R_Mesh_ColorPointer(rsurface.array_color4f, 0, 0);
for (texturesurfaceindex = 0;texturesurfaceindex < texturenumsurfaces;texturesurfaceindex++)
{
int i;
rtexture_t *shirttexture = rsurface.texture->currentskinframe->shirt;
qboolean dopants = pantstexture && VectorLength2(surfacepants) >= (1.0f / 1048576.0f);
qboolean doshirt = shirttexture && VectorLength2(surfaceshirt) >= (1.0f / 1048576.0f);
- rmeshstate_t m;
ambientscale *= 2 * r_refdef.view.colorscale;
diffusescale *= 2 * r_refdef.view.colorscale;
ambientcolorbase[0] = lightcolor[0] * ambientscale * surfacecolor[0];ambientcolorbase[1] = lightcolor[1] * ambientscale * surfacecolor[1];ambientcolorbase[2] = lightcolor[2] * ambientscale * surfacecolor[2];
diffusecolorpants[0] = diffusecolorbase[0] * surfacepants[0];diffusecolorpants[1] = diffusecolorbase[1] * surfacepants[1];diffusecolorpants[2] = diffusecolorbase[2] * surfacepants[2];
ambientcolorshirt[0] = ambientcolorbase[0] * surfaceshirt[0];ambientcolorshirt[1] = ambientcolorbase[1] * surfaceshirt[1];ambientcolorshirt[2] = ambientcolorbase[2] * surfaceshirt[2];
diffusecolorshirt[0] = diffusecolorbase[0] * surfaceshirt[0];diffusecolorshirt[1] = diffusecolorbase[1] * surfaceshirt[1];diffusecolorshirt[2] = diffusecolorbase[2] * surfaceshirt[2];
+ R_Mesh_TexBind(0, R_GetTexture(basetexture));
+ R_Mesh_TexMatrix(0, &rsurface.texture->currenttexmatrix);
+ R_Mesh_TexCombine(0, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(0, 2, rsurface.texcoordtexture2f, rsurface.texcoordtexture2f_bufferobject, rsurface.texcoordtexture2f_bufferoffset);
switch(r_shadow_rendermode)
{
case R_SHADOW_RENDERMODE_LIGHT_VERTEX3DATTEN:
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(basetexture);
- m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- m.tex3d[1] = R_GetTexture(r_shadow_attenuation3dtexture);
- m.texmatrix[1] = rsurface.entitytoattenuationxyz;
- m.pointer_texcoord3f[1] = rsurface.vertex3f;
- m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
- m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBindAll(1, 0, R_GetTexture(r_shadow_attenuation3dtexture), 0, 0);
+ R_Mesh_TexMatrix(1, &rsurface.entitytoattenuationxyz);
+ R_Mesh_TexCombine(1, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(1, 3, rsurface.vertex3f, rsurface.vertex3f_bufferobject, rsurface.vertex3f_bufferoffset);
break;
case R_SHADOW_RENDERMODE_LIGHT_VERTEX2D1DATTEN:
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(basetexture);
- m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
- m.texmatrix[1] = rsurface.entitytoattenuationxyz;
- m.pointer_texcoord3f[1] = rsurface.vertex3f;
- m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
- m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- m.tex[2] = R_GetTexture(r_shadow_attenuation2dtexture);
- m.texmatrix[2] = rsurface.entitytoattenuationz;
- m.pointer_texcoord3f[2] = rsurface.vertex3f;
- m.pointer_texcoord_bufferobject[2] = rsurface.vertex3f_bufferobject;
- m.pointer_texcoord_bufferoffset[2] = rsurface.vertex3f_bufferoffset;
- R_Mesh_TextureState(&m);
- break;
+ R_Mesh_TexBind(2, R_GetTexture(r_shadow_attenuation2dtexture));
+ R_Mesh_TexMatrix(2, &rsurface.entitytoattenuationz);
+ R_Mesh_TexCombine(2, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(2, 3, rsurface.vertex3f, rsurface.vertex3f_bufferobject, rsurface.vertex3f_bufferoffset);
+ // fall through
case R_SHADOW_RENDERMODE_LIGHT_VERTEX2DATTEN:
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(basetexture);
- m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- m.tex[1] = R_GetTexture(r_shadow_attenuation2dtexture);
- m.texmatrix[1] = rsurface.entitytoattenuationxyz;
- m.pointer_texcoord3f[1] = rsurface.vertex3f;
- m.pointer_texcoord_bufferobject[1] = rsurface.vertex3f_bufferobject;
- m.pointer_texcoord_bufferoffset[1] = rsurface.vertex3f_bufferoffset;
- R_Mesh_TextureState(&m);
+ R_Mesh_TexBind(1, R_GetTexture(r_shadow_attenuation2dtexture));
+ R_Mesh_TexMatrix(1, &rsurface.entitytoattenuationxyz);
+ R_Mesh_TexCombine(1, GL_MODULATE, GL_MODULATE, 1, 1);
+ R_Mesh_TexCoordPointer(1, 3, rsurface.vertex3f, rsurface.vertex3f_bufferobject, rsurface.vertex3f_bufferoffset);
break;
case R_SHADOW_RENDERMODE_LIGHT_VERTEX:
- memset(&m, 0, sizeof(m));
- m.tex[0] = R_GetTexture(basetexture);
- m.texmatrix[0] = rsurface.texture->currenttexmatrix;
- m.pointer_texcoord[0] = rsurface.texcoordtexture2f;
- m.pointer_texcoord_bufferobject[0] = rsurface.texcoordtexture2f_bufferobject;
- m.pointer_texcoord_bufferoffset[0] = rsurface.texcoordtexture2f_bufferoffset;
- R_Mesh_TextureState(&m);
break;
default:
break;