Hello all,
A bit of a wierd thing is happening and I’ve no idea why. I’m loading a bunch of textures as follows:
glBindTexture(GL_TEXTURE_2D, texBindNum);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, image->w, image->h, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB, GL_UNSIGNED_BYTE, image->pixels);
Then, when I want to use a given texture I just:
glBindTexture(GL_TEXTURE_2D, theTex);
NOTE: I don’t need to call glEnable(GL_TEXTURE_2D) because I’m doing my texturing from the shaders…
My vert shader looks like:
gl_TexCoord[0] = gl_MultiTexCoord0;
And my frag shader looks like:
vec4 color = texture2D(tex,gl_TexCoord[0].st);
gl_FragColor = color;
where “tex” is a uniform sampler2D.
And now to the problem…
Instead of accesing the texture I’ve just glBind-ed, everything seems to be textured with the last texture to be loaded…I.e. glBindTexture has no effect. If I change the order of loading for the textures, it’s always the last to be loaded that seems to be somehow permanently bound.
Any ideas what I could be doing wrong?
cheers,
g.