Multitex element array problem

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?

Try uisng glActiveTextureARB() too, not just glClientActiveTextureARB(). There might be some confusion in the state vectors.

(Texcoord pointers should be client state, but you never know.)

[This message has been edited by StefanG (edited 11-21-2002).]

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.