Skip to main content
GameDev.net gamedev.net
🔒 Locked

multitexture with vbos

Started by supagu Mar 31, 2004 at 7:04 AM 0 replies 650+ views
Original Post
supagu
supagu
hrmm i have just got multitexture working, but it wont let me change the textures?
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable(GL_TEXTURE_2D);
material->SetMaterial(0); //just binds texture



glEnableClientState( GL_VERTEX_ARRAY );
		glEnableClientState( GL_INDEX_ARRAY );

		glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboPositions );
		glVertexPointer( 3, GL_FLOAT, sizeof(Vector3), 0 );	

		if( uvCoords != 0 )
		{
			glEnableClientState( GL_TEXTURE_COORD_ARRAY );

			//if( gluxIsAvailable("GL_ARB_multitexture") == GLUX_AVAILABLE  )

			//	glClientActiveTexture( GL_TEXTURE0_ARB );


			glClientActiveTexture( GL_TEXTURE0_ARB );
			glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboTexCoords );
			glTexCoordPointer( 2, GL_FLOAT, sizeof(UVCoord), 0 );
		}
		
		glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, vboIndices );
		glIndexPointer( GL_UNSIGNED_INT, sizeof(unsigned int), 0 );


	if( uvCoords2 != 0 && material->texture2 != 0 )
		{
			//set second channel

			glActiveTextureARB( GL_TEXTURE1_ARB );
			glEnable(GL_TEXTURE_2D);

			material->texture2->SetTexture(1);

			glClientActiveTexture( GL_TEXTURE1_ARB );
			glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboTexCoords2 );
			glTexCoordPointer( 2, GL_FLOAT, sizeof(UVCoord), 0 );

		}
					

		glDrawElements( GL_TRIANGLES, noPolys*3, GL_UNSIGNED_INT, 0);
		polys += noPolys;

		glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
        glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );

is there something wrong some where? the first texture should be changing, while the second texture is my lightmap, it blends the textures great (is there some option to vary how they are combined? ) but the problem is, say i have a road texture and grass texture, the whole map ends up being rendered with the road texture for seom reason... even the skybox which doesnt use VBOs?!
supagu
supagu
okay i got it working, but the sky and my font (which dont use vbo''s) are all really dark, how to i restore it back so these work also?

i have tried:
glDisableClientState( GL_TEXTURE_COORD_ARRAY );

but this doesnt fix the sky and font :-/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.