Has anybody used the GLUT built-in geometric objects (glutWireTeapot in my case) along with CG? My teapot is going through some strange translations when passed through a CG shader, but non-GLUT vertices that are going through the same shader show up where I expect them to. Has anybody else run across this problem? Thanks.

Hi,
you probably set your Modelviewmatrix for CG right before you call glutSolidTeapot() - but this call has a internal translation - that’s why the teapot isn’t at the desired position. Just use the ARB vertex profile and lookup the Modelview Matrix with the “glstate” variables. that should solve the problem.

Don’t forget to check nVidia’s documentation, especially about Cg Toolkit, an important part talk about moving into 3D space through Cg, something like that…

I had the same problem. I solved it by manually applying the internal transformations used by the glut shapes. I have a function gltutMultShapeMatrix(int shape) which applys the transformations based on the shape enumeration.

glPushMatrix();
gltutMultShapeMatrix(live_shape);
cgGLSetStateMatrixParameter(model_view, CG_GL_MODELVIEW_MATRIX,CG_GL_MATRIX_IDENTITY);
cgGLSetStateMatrixParameter(model_view_IT, CG_GL_MODELVIEW_MATRIX,CG_GL_MATRIX_INVERSE_TRANSPOSE );
cgGLSetStateMatrixParameter(model_view_projection, CG_GL_MODELVIEW_PROJECTION_MATRIX,CG_GL_MATRIX_IDENTITY);
cgGLSetStateMatrixParameter(projection, CG_GL_PROJECTION_MATRIX,CG_GL_MATRIX_IDENTITY);
glPopMatrix();
// shader stuff
// ...
// render shape based on id
gltutRenderShape(live_shape,live_wireframe==1);

If you are interested, I could send you the code for all glut shapes with proper transformations. I also added texture coordinates for shapes like the cone and the torus.

Also, don’t forget that the glut-teapot is a NURBS-surface (not that it should matter), and that it’s defined with cw-winding, not ccw (this might matter)

ScottManDeath, thanks for the offer; I would be interested in seeing that code. It’s really for my own curiosity, though…I don’t need it for anything important, so don’t put yourself to too much trouble.

For my “ÜberShapeRender” function , If you send me your email address (e.g. via Private Message), I’ll send you the code, it would be to much to post here directly. Don’t expect to much, the function is just there to conveniently render some shapes.