}
}
-void R_Mesh_TexBind3D(unsigned int unitnum, int texnum)
-{
- gltextureunit_t *unit = gl_state.units + unitnum;
- if (unitnum >= vid.teximageunits)
- return;
- // update 2d texture binding
- if (unit->t2d)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->t2d)
- {
- qglDisable(GL_TEXTURE_2D);CHECKGLERROR
- }
- }
- unit->t2d = 0;
- qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
- }
- // update 3d texture binding
- if (unit->t3d != texnum)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (texnum)
- {
- if (unit->t3d == 0)
- {
- qglEnable(GL_TEXTURE_3D);CHECKGLERROR
- }
- }
- else
- {
- if (unit->t3d)
- {
- qglDisable(GL_TEXTURE_3D);CHECKGLERROR
- }
- }
- }
- unit->t3d = texnum;
- qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
- }
- // update cubemap texture binding
- if (unit->tcubemap != 0)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->tcubemap)
- {
- qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
- }
- }
- unit->tcubemap = 0;
- qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
- }
- // update rectangle texture binding
- if (unit->trectangle != 0)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->trectangle)
- {
- qglDisable(GL_TEXTURE_RECTANGLE_ARB);CHECKGLERROR
- }
- }
- unit->trectangle = 0;
- qglBindTexture(GL_TEXTURE_RECTANGLE_ARB, unit->trectangle);CHECKGLERROR
- }
-}
-
-void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum)
-{
- gltextureunit_t *unit = gl_state.units + unitnum;
- if (unitnum >= vid.teximageunits)
- return;
- // update 2d texture binding
- if (unit->t2d)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->t2d)
- {
- qglDisable(GL_TEXTURE_2D);CHECKGLERROR
- }
- }
- unit->t2d = 0;
- qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
- }
- // update 3d texture binding
- if (unit->t3d)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->t3d)
- {
- qglDisable(GL_TEXTURE_3D);CHECKGLERROR
- }
- }
- unit->t3d = 0;
- qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
- }
- // update cubemap texture binding
- if (unit->tcubemap != texnum)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (texnum)
- {
- if (unit->tcubemap == 0)
- {
- qglEnable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
- }
- }
- else
- {
- if (unit->tcubemap)
- {
- qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
- }
- }
- }
- unit->tcubemap = texnum;
- qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
- }
- // update rectangle texture binding
- if (unit->trectangle != 0)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->trectangle)
- {
- qglDisable(GL_TEXTURE_RECTANGLE_ARB);CHECKGLERROR
- }
- }
- unit->trectangle = 0;
- qglBindTexture(GL_TEXTURE_RECTANGLE_ARB, unit->trectangle);CHECKGLERROR
- }
-}
-
-void R_Mesh_TexBindRectangle(unsigned int unitnum, int texnum)
-{
- gltextureunit_t *unit = gl_state.units + unitnum;
- if (unitnum >= vid.teximageunits)
- return;
- // update 2d texture binding
- if (unit->t2d)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->t2d)
- {
- qglDisable(GL_TEXTURE_2D);CHECKGLERROR
- }
- }
- unit->t2d = 0;
- qglBindTexture(GL_TEXTURE_2D, unit->t2d);CHECKGLERROR
- }
- // update 3d texture binding
- if (unit->t3d)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->t3d)
- {
- qglDisable(GL_TEXTURE_3D);CHECKGLERROR
- }
- }
- unit->t3d = 0;
- qglBindTexture(GL_TEXTURE_3D, unit->t3d);CHECKGLERROR
- }
- // update cubemap texture binding
- if (unit->tcubemap != 0)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (unit->tcubemap)
- {
- qglDisable(GL_TEXTURE_CUBE_MAP_ARB);CHECKGLERROR
- }
- }
- unit->tcubemap = 0;
- qglBindTexture(GL_TEXTURE_CUBE_MAP_ARB, unit->tcubemap);CHECKGLERROR
- }
- // update rectangle texture binding
- if (unit->trectangle != texnum)
- {
- GL_ActiveTexture(unitnum);
- if (unitnum < vid.texunits)
- {
- if (texnum)
- {
- if (unit->trectangle == 0)
- {
- qglEnable(GL_TEXTURE_RECTANGLE_ARB);CHECKGLERROR
- }
- }
- else
- {
- if (unit->trectangle)
- {
- qglDisable(GL_TEXTURE_RECTANGLE_ARB);CHECKGLERROR
- }
- }
- }
- unit->trectangle = texnum;
- qglBindTexture(GL_TEXTURE_RECTANGLE_ARB, unit->trectangle);CHECKGLERROR
- }
-}
-
static const float gl_identitymatrix[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix)
void R_Mesh_TexCoordPointer(unsigned int unitnum, unsigned int numcomponents, const float *texcoord, int bufferobject, size_t bufferoffset);
// sets all textures bound to an image unit (multiple can be non-zero at once, according to OpenGL rules the highest one overrides the others)
void R_Mesh_TexBindAll(unsigned int unitnum, int tex2d, int tex3d, int texcubemap, int texrectangle);
-// sets these are like TexBindAll with only one of the texture indices non-zero
-// (binds one texture type and unbinds all other types)
+// equivalent to R_Mesh_TexBindAll(unitnum,tex2d,0,0,0)
void R_Mesh_TexBind(unsigned int unitnum, int texnum);
-void R_Mesh_TexBind3D(unsigned int unitnum, int texnum);
-void R_Mesh_TexBindCubeMap(unsigned int unitnum, int texnum);
-void R_Mesh_TexBindRectangle(unsigned int unitnum, int texnum);
// sets the texcoord matrix for a texenv unit
void R_Mesh_TexMatrix(unsigned int unitnum, const matrix4x4_t *matrix);
// sets the combine state for a texenv unit
// do global setup needed for the chosen lighting mode
if (r_shadow_rendermode == R_SHADOW_RENDERMODE_LIGHT_GLSL)
{
- R_Mesh_TexBindCubeMap(GL20TU_CUBE, R_GetTexture(rsurface.rtlight->currentcubemap)); // light filter
+ R_Mesh_TexBindAll(GL20TU_CUBE, 0, 0, R_GetTexture(rsurface.rtlight->currentcubemap), 0); // light filter
GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 0);
CHECKGLERROR
if (shadowmapping)
else if (r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAPRECTANGLE)
{
r_shadow_usingshadowmaprect = true;
- R_Mesh_TexBindRectangle(GL20TU_SHADOWMAPRECT, R_GetTexture(r_shadow_shadowmaprectangletexture));
+ R_Mesh_TexBindAll(GL20TU_SHADOWMAPRECT, 0, 0, 0, R_GetTexture(r_shadow_shadowmaprectangletexture));
CHECKGLERROR
}
else if (r_shadow_shadowmode == R_SHADOW_SHADOWMODE_SHADOWMAPCUBESIDE)
{
r_shadow_usingshadowmapcube = true;
- R_Mesh_TexBindCubeMap(GL20TU_SHADOWMAPCUBE, R_GetTexture(r_shadow_shadowmapcubetexture[r_shadow_shadowmaplod]));
+ R_Mesh_TexBindAll(GL20TU_SHADOWMAPCUBE, 0, 0, R_GetTexture(r_shadow_shadowmapcubetexture[r_shadow_shadowmaplod]), 0);
CHECKGLERROR
}
if (r_shadow_shadowmapvsdct && (r_shadow_usingshadowmap2d || r_shadow_usingshadowmaprect))
{
- R_Mesh_TexBindCubeMap(GL20TU_CUBEPROJECTION, R_GetTexture(r_shadow_shadowmapvsdcttexture));
+ R_Mesh_TexBindAll(GL20TU_CUBEPROJECTION, 0, 0, R_GetTexture(r_shadow_shadowmapvsdcttexture), 0);
CHECKGLERROR
}
}