Vertex Array + Multitexture Probs

Started by
4 comments, last by biggy 17 years, 6 months ago
basically i am trying to render my terrain using vertex arrays. But when i try to multitexture only the ground texture is rendered (detailmap does not render). it works when i am using ordinary lists, but when i tried vertex arrays I can't get both texs to render no matter work. I've tried all sorts (plus most of the solutions posted on here) with little success. Here is my code i am using. I think this is the 'proper' way to do it but it doesn't seem to work. maybe i am missing something somewhere else??
void RenderVertexArray()
{
 

for(int z=0; z<m_iNumPatchesPerSide; z++)
	for(int x=0; x<m_iNumPatchesPerSide; x++)
	{	
		i = GetPatchNumber(x, z);
		
		if( m_bpPatchVisible )
		{
			iNumIndices = m_iNumIndices[ m_pPatches[GetPatchNumber(x, z)].m_iLOD ];
			
			// Setup first tex coords (ground)
			glClientActiveTextureARB( GL_TEXTURE0_ARB );
			glEnableClientState( GL_TEXTURE_COORD_ARRAY );
			glTexCoordPointer(2, GL_FLOAT, sizeof(GeoTex), m_vTex + (m_iNumVertsPerPatch * i));
			
			// setup 2nd tex coords (detailmap)
			glClientActiveTextureARB( GL_TEXTURE1_ARB );
			glEnableClientState( GL_TEXTURE_COORD_ARRAY );
			glTexCoordPointer(2, GL_FLOAT, sizeof(GeoTex), m_vTex2 + (m_iNumVertsPerPatch * i));
			
			
			// bind ground tex
			glActiveTextureARB( GL_TEXTURE0_ARB );
			glEnable( GL_TEXTURE_2D );
			glBindTexture( GL_TEXTURE_2D, m_Texture.GetID() );
			
			// bind detail tex
			glActiveTextureARB( GL_TEXTURE1_ARB );
			glEnable( GL_TEXTURE_2D );
			glBindTexture( GL_TEXTURE_2D, m_DetailMap.GetID() );
			glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
			glTexEnvi( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2 );	
			
			glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(GeoNorm), m_vNormal + (m_iNumVertsPerPatch * i) );
			glVertexPointer(3, GL_FLOAT, sizeof(GeoVertex), m_vVertices + (m_iNumVertsPerPatch * i) );
			
			glDrawElements( GL_TRIANGLES, iNumIndices, GL_UNSIGNED_SHORT, usIndices);
		}
	}
	
	glDisable( GL_BLEND );
	
	// unbind detail tex
	glActiveTextureARB( GL_TEXTURE1_ARB );
	glDisable( GL_TEXTURE_2D );
	glBindTexture( GL_TEXTURE_2D, 0 );
	
	// unbind ground tex
	glActiveTextureARB( GL_TEXTURE0_ARB );
	glDisable( GL_TEXTURE_2D );
	glBindTexture( GL_TEXTURE_2D, 0 );

}


Advertisement
I think you should disable the GL_TEXTURE_COORD_ARRAY like you enabled it.

glClientActiveTexture(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTexture(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

(... and the other disablings..)
yeah i tried fiddling with those enable/disable statements in so many different ways but none of it makes a difference somehow.
How exactly are you wanting to combine the two textures? You don't seem to be setting up the texture environment fully.
i want to combine a detail map with the terrain texture to get a more detailed look. As I said this works using the usual multitexturing way when I am not using vertex arrays. The above seems like it should work but does not.
Fixed it.

turns out the multitexture code was fine but the tex coords were not set up right. So it was multitexturing but in such a way that it didn't look like it. whoops.

Sorry about that.

This topic is closed to new replies.

Advertisement