PDA

View Full Version : displaying a 3d primative (glut)



true_atlantis
09-03-2005, 11:05 AM
im extremly new to opengl, and i understand how to display 2d primatives, but when it comes to 3d, i get confused. how do you specify where they are in the window? for example

glutSolidTeapot(1.0)

will show a cutoff teapot at the bottom left corner, but how do i make it appear somewhere else?? thanks

dvm
09-03-2005, 12:01 PM
It depends on the transformation matrix. Try finding the red book online (it's an older version, but the basic stuff that you need is there). It's in this site somewhere.
In essence you should use glTransform*, glRotate*, glScale* to move ("transform") your object in the "world coordinates". Hope I've shed some light, welcome to the wonderful world of OpenGL ;)

true_atlantis
09-03-2005, 12:55 PM
ok, im sort of getting the hang of it. for example, i have global variables int_x int_y and zoom and to display the object, i do this

glLoadIdentity();
glTranslatef(int_x, int_y, 1.0);
glutWireTeapot(zoom);

but that just gives me the image in the xy plane, how do i view it from a different angle? for example, xz or yz planes? thanks

memfr0b
09-03-2005, 03:21 PM
You can rotate using one of the glRotate* calls. Or if you like to think in terms of a camera, use gluLookAt to specify the camera position, lookat point and up-vector.