(I posted this is the linux section, but that forum looks rather dead.)
I am trying to use an indexed array to draw a multitextured scene as follows:
// load vertices
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer (2, GL_FLOAT, v_stride, pVertices);
// load normals
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, n_stride, pNormals);
// set unit 0
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, t_stride0, pTexCoords0);
glBindTexture(GL_TEXTURE_2D, base_texture);
// set unit 1
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, t_stride1, pTexCoords0);
glBindTexture(GL_TEXTURE_2D, lightmap);
// draw it.
glDrawElements(GL_TRIANGLES, numIndexes, GL_UNSIGNED_SHORT, pIndexes);
The problem is that the texture coordinates intended for unit 1 are actually overwriting the ones intended for unit 0, and unit 1 coordinates are never initilized. So it looks like glTexCoordPointer() is stuck on unit 0. How do I tell glTexCoordPointer that the data is intended for a texture unit other than 0?
(I’ve looked at a number of tutorials and examples, and I can’t see anything wrong with the above code, which makes me start wondering if the NVidia opengl on linux has a bug.)