PDA

View Full Version : rotating object using opengl api - possible ?



11-08-2002, 11:28 AM
Hi,
I was wondering if it's possible to use opengl API to rotate arbitrary objects before drawing to the context. Say you have 2 cubes and you'd like to rotate one clockwise and the other one counterclockwise and then draw them both and apply other transformations via opengl matrices. Is it possible to speed up things and use opengl api to perform those initial rotations or do you have to write your own code to rotate the cubes and then use opengl to rotate the entire world ?
Thanks,

Martin

nexusone
11-08-2002, 11:52 AM
I can not answer on the speed, but of course you can rotate two indepent objects via the use of glPush/PopMatrix.

example:

glRotatef(world_rotation);

glPushMatrix();
glrotatef(object_1_rotation)
draw_object_1();
glPopMatrix();

glPushMatrix();
glRotatef(object_2_rotation)
draw_object_2();
glPopMatrix();



Originally posted by Martin_uniqueusername:
Hi,
I was wondering if it's possible to use opengl API to rotate arbitrary objects before drawing to the context. Say you have 2 cubes and you'd like to rotate one clockwise and the other one counterclockwise and then draw them both and apply other transformations via opengl matrices. Is it possible to speed up things and use opengl api to perform those initial rotations or do you have to write your own code to rotate the cubes and then use opengl to rotate the entire world ?
Thanks,

Martin

mm_freak
11-08-2002, 04:45 PM
You shouldn't rotate the world. Rotate the camera in the other direction and you'll have the same effect, but that should be faster.

nexusone
11-08-2002, 05:38 PM
Don't confuse the boy.... there is no camera in openGL, openGL just simulates it by moving the world around.



Originally posted by mm_freak:
You shouldn't rotate the world. Rotate the camera in the other direction and you'll have the same effect, but that should be faster.

mm_freak
11-08-2002, 07:29 PM
In the programmers view, there is a camera and how it's done internally is just a matter for the implementor, not the programmer. An implementor CAN use a camera. As long as it's conform to the OpenGL specification, an implementor can implement it the way he likes.