Jump to content
  • Advertisement
Sign in to follow this  

void TangentPointerEXT with Cg ????

This topic is 3791 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
that makes sense... but im confused how i would use the pointer... i dont see a gltexcoord2pointer.... so how do i call that or use that?

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!