rotating object using opengl api - possible ?

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

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:
[b]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[/b]

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.

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.

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.