void TangentPointerEXT with Cg ????

Started by
3 comments, last by AverageJoeSSU 16 years, 1 month ago
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?

------------------------------

redwoodpixel.com

Advertisement
glTangentPointerEXT is part of which extension?
Also, why don't you submit the tangent through another texcoord?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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?
thanks

------------------------------

redwoodpixel.com

You would do something like this (using your code):

//for your normal texture coordsglClientActiveTexture(GL_TEXTURE0); //set the active texture to texture0glEnableClientState(GL_TEXTURE_COORD_ARRAY); //enable texture coord array for texture0glTexCoordPointer(MeshPointer->model.getTexCoordSize(), GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledTexCoordOffset() );//for your tangentsglClientActiveTexture(GL_TEXTURE1); //set the active texture to whatever texture you want to use for tangents, in this example texture1glEnableClientState(GL_TEXTURE_COORD_ARRAY); //enable texture coord array for texture1//make sure to pass 3 as the first argument as tangents have 3 coordinatesglTexCoordPointer(3, GL_FLOAT, MeshPointer->model.getCompiledVertexSize() * sizeof(float), MeshPointer->model.getCompiledVertices() + MeshPointer->model.getCompiledTangentOffset())//do rest of setup and draw here//disableglClientActiveTexture(GL_TEXTURE0);glDisableClientState(GL_TEXTURE_COORD_ARRAY);glClientActiveTexture(GL_TEXTURE1);glDisableClientState(GL_TEXTURE_COORD_ARRAY);


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

------------------------------

redwoodpixel.com

This topic is closed to new replies.

Advertisement