Multitexturing and vertex arrays?

I cant seem to get the textures to come out properly. The vertices and normals do but not the textures. im doing.
Application:

 
		glEnableClientState( GL_VERTEX_ARRAY );
						glVertexPointer( 3,   GL_FLOAT, stride, m_pTMVertexArray[lTile][lMask] +0 );
						 
						glEnableClientState( GL_NORMAL_ARRAY );
						glNormalPointer(  GL_FLOAT, stride, m_pTMVertexArray[lTile][lMask] + 3 );
						
						glClientActiveTextureARB(GL_TEXTURE0_ARB  );
						glEnable( GL_TEXTURE_2D );
						glBindTexture(GL_TEXTURE_2D,  m_pTextureIDsVertexArray[lTile][lMask][0]);
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST  );
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
						glEnableClientState( GL_TEXTURE_COORD_ARRAY );
						glTexCoordPointer( 2, GL_FLOAT, stride, m_pTMVertexArray[lTile][lMask] + 6  );  //use the modified one caues its 0- m_iSize
						
						
						glClientActiveTextureARB(GL_TEXTURE1_ARB );
						glEnable( GL_TEXTURE_2D );
						glBindTexture(GL_TEXTURE_2D,  m_pTextureIDsVertexArray[lTile][lMask][1]);
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST  );
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
						glEnableClientState( GL_TEXTURE_COORD_ARRAY );
						glTexCoordPointer( 2, GL_FLOAT, stride, m_pTMVertexArray[lTile][lMask] + 8  );  //use
					 
						//render using a base texture and vertex info
						
						glDrawArrays( GL_QUADS, 0, m_TMNumVertices[lTile][lMask] );
						
						
						glDisableClientState( GL_VERTEX_ARRAY );

						glDisableClientState( GL_NORMAL_ARRAY );
						
						glClientActiveTextureARB(GL_TEXTURE0_ARB);
						glDisableClientState( GL_TEXTURE_COORD_ARRAY );
						glDisable( GL_TEXTURE_2D );
						
						glClientActiveTextureARB(GL_TEXTURE1_ARB);
						glDisableClientState( GL_TEXTURE_COORD_ARRAY );
						glDisable( GL_TEXTURE_2D );
						
					 	//glClientActiveTextureARB(GL_TEXTURE2_ARB);
					 	//glDisableClientState( GL_TEXTURE_COORD_ARRAY );
					 	//glDisable( GL_TEXTURE_2D );
					
 

The shader goes like this…

 

uniform sampler2D RoamTex;
uniform sampler2D AlphaTexC1;

...
...

 

The result is a texture from another part of my program getting drawn,

Any ideas,?

Thanks

forgot this too.

before the above code i set shader texture uniform variables for the textures

  
	m_roamShader.UseShaders (true);				
				
				m_roamShader.Update1DiVariable ("RoamTex",0);
				m_roamShader.Update1DiVariable ("AlphaTexC1",1);
			

You are getting glClientActiveTexture confused with glActiveTexture (Which you are not doing).

glClientActiveTexture is for setting up client states like the source texture coordinates in vertex arrays. (glEnableClientState, glTexCoordPointer)

glActiveTexture is for the server side state. All these calls:
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D,m_pTextureIDsVertexArray[lTile][lMask][1]);
glTexParameterf(…)

are server side…

If you are in any doubt about what textures are bound where, might I suggest you grab a XML frame with GLIntercept (http://glintercept.nutty.org) and inspect the render call?

Should look like this: http://glintercept.nutty.org/Demo03/gliInterceptLog.xml

Great! Thanks for the help , it works now and more importantly i understand why.

As an aside note on the missing textures i had, i noticed that if I didnt mipmap my textures with gluBuildMipMaps and then called the following code
the texture was always black? Just curious why

  
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST  );
						glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
					

Thanks again.

thanks also fo the GLIntercept link!

The black texture is from enabling mip-mapping but not supplying all the mipmaps. This is a common mistake people make.

When you specify GL_LINEAR_MIPMAP_NEAREST (or anything with MIPMAP in the name) it enables mipmapping on that texture.

Mipmapping can only be defined for the GL_TEXTURE_MIN_FILTER!
The GL_TEXTURE_MAG_FILTER can only be set to GL_NEAREST or GL_LINEAR!

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