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.
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…
That glState trick worked. Out of curiosity, is there any way to make this work in a non-ARB profile? Thanks to both of you for your help.
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.
cgGLSetStateMatrixParameter(model_view_IT, CG_GL_MODELVIEW_MATRIX,CG_GL_MATRIX_INVERSE_TRANSPOSE );
// shader stuff
// render shape based on id
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.
The code can be found in the source code of GLUT, here is the important stuff
Transformations done internally by glutTeapot, scale is the parameter:
glRotatef(270.0, 1.0, 0.0, 0.0);
glScalef(0.5 * scale, 0.5 * scale, 0.5 * scale);
glTranslatef(0.0, 0.0, -1.5);
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.