Sign in to follow this  

void TangentPointerEXT with Cg ????

Recommended Posts

whats the deal with this function anyways... i am trying to pass in tangents and its not working ie segfaulting, and i double check the address and its the same as the normals (cause the use the same array different offset). I am using Cg shaders. Anyways... here is the code... hopefully someone knows whats up...
// start nvmodel rendering code
		glNormalPointer( GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledNormalOffset());
//		glTangentPointerEXT( GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), (void*)(MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledTangentOffset()));
		glVertexPointer( MeshPointer->model.getPositionSize(), GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices());
		glTexCoordPointer( MeshPointer->model.getTexCoordSize(), GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledTexCoordOffset());
		glEnableClientState( GL_VERTEX_ARRAY);
		glEnableClientState( GL_NORMAL_ARRAY);
//		glEnableClientState( GL_TANGENT_ARRAY_EXT);
		glEnableClientState( GL_TEXTURE_COORD_ARRAY);

		glDrawElements( GL_TRIANGLES, MeshPointer->model.getCompiledIndexCount( nv::Model::eptTriangles), GL_UNSIGNED_INT, MeshPointer->model.getCompiledIndices( nv::Model::eptTriangles));

		glDisableClientState( GL_VERTEX_ARRAY);
		glDisableClientState( GL_NORMAL_ARRAY);
//		glDisableClientState( GL_TANGENT_ARRAY_EXT);
		glDisableClientState( GL_TEXTURE_COORD_ARRAY);		// end nvmodel rendering code

is there anymore initialization or anymore info about passing tangents this way?

Share this post

Link to post
Share on other sites
glTangentPointerEXT is part of which extension?
Also, why don't you submit the tangent through another texcoord?

Share this post

Link to post
Share on other sites
You would do something like this (using your code):

//for your normal texture coords
glClientActiveTexture(GL_TEXTURE0); //set the active texture to texture0
glEnableClientState(GL_TEXTURE_COORD_ARRAY); //enable texture coord array for texture0
glTexCoordPointer(MeshPointer->model.getTexCoordSize(), GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledTexCoordOffset() );

//for your tangents
glClientActiveTexture(GL_TEXTURE1); //set the active texture to whatever texture you want to use for tangents, in this example texture1
glEnableClientState(GL_TEXTURE_COORD_ARRAY); //enable texture coord array for texture1

//make sure to pass 3 as the first argument as tangents have 3 coordinates
glTexCoordPointer(3, GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledTangentOffset())

//do rest of setup and draw here



Also, last I heard, neither Nvidia nor Ati implements the TangentPointerEXT extension in their drivers.

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