Sign in to follow this  
Paul_H

multitexturing with vertex arrays

Recommended Posts

Im working on a morphing app, im using the ARBmultitexture extension for merging the textures, when I render the models using standard glBegin(GL_TRIANGLE_STRIP) approach it works fine, when I switch to using vertex arrays my textures fade to white. Heres a sample of my code:
	glClientActiveTextureARB( GL_TEXTURE0_ARB );
	glTexCoordPointer(2, GL_FLOAT, 0, texcoord1[0]);   
	glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
    
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
	
	glClientActiveTextureARB(GL_TEXTURE1_ARB );
	glTexCoordPointer(2, GL_FLOAT, 0, texcoord2[0]);   
	glEnableClientState(GL_TEXTURE_COORD_ARRAY); 
    
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB );
    glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB );

    glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB );
    glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );

    glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE );
    glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );

    glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB );
    glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR );
	

	glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture( GL_TEXTURE_2D, texture1 );

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture( GL_TEXTURE_2D, texture2 );

    glColor3f( blendvalue, blendvalue, blendvalue); //blend value [0..1]

	glVertexPointer(3, GL_FLOAT, 0, vertices);
	glDrawElements(GL_TRIANGLE_STRIP , numofindices , GL_UNSIGNED_SHORT , indices);


I also have vertex normals defined but whenever I enable lighting it seems to stop multitexturing from working. If anyone could offer any advice as to how I could stop the textures fading to white when blendvalue approaches 1, or how I could get lighting to work, I am aware I need a normal pointer, then I would be very grateful.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this