i’m loading my shader from a xml description fill, where i define shaders textures and models. every textures has an id, which can be used to link the shader to an texture by setting up uniform sampler variable.
<model src="./models/woman.3ds"></model>
<texture name="pBuffer" id="0" type="pBuffer"></texture>
<texture name="bane" id="1" src="./textures/bane.tif"></texture>
<texture name="womanBaseImage" id="2" src="./textures/JudyBodyTexLo.tif"></texture>
<shaderProgram id="1">
<uniform name="baseImage" type="sampler2D">2</uniform>
<uniform name="shadowMap" type="sampler2D">0</uniform>
<uniform name="faceShadowFactor" type="float">1.0</uniform>
<uniform name="zAdjustment" type="float">0.01</uniform>
<vertexShader name="vgl2_TextureSpaceLighting" src="./shaders/TextureSpaceLighting.vert">
</vertexShader>
<fragmentShader name="fgl2_TextureSpaceLighting" src="./shaders/TextureSpaceLighting.frag">
</fragmentShader>
</shaderProgram>
because of the dynamic texture an shader loading i can code the ids in my shaders hard. let the following be my vertex shader code.
uniform sampler2D baseImage; // base texture
uniform sampler2D shadowMap; // shadow map
void main(void)
{
gl_TexCoord[0] = gl_MultiTexCoord0;
}
depening of the texture ids in my xml description file the index of my gl_TexCoord[] have to vary. for example the texture id for my baseImage is two. then my program is binding the texture to texture name and unit 2. same for uniform sampler2D baseImage. this value is also set to 2. the outcome of this is i have to set gl_TexCoord[2] in my shader. so the index depends directly on uniform sampler2D baseImage.
so i need something like the integer value of the 2d tetxure handle. something like a case …