PDA

View Full Version : Little help, Rotation



monson
11-06-2000, 02:42 PM
Hi all, I'm new to openGL, but I have programmed in DirectX for a while now. I am making a "hello world" type or program, which basically consists of a texture mapped sphere that is rotating on its Y-axis (up). In DirectX we had a function SetRotation, which sets the object rotation and you don't have to worry about it anymore the object will rotate without any Rotation call in the main rendering loop. Is there anything like that in openGL ? if not, can you recommend the best way to do it?

any help is appreciated, thanks

DFrey
11-06-2000, 03:31 PM
Unlike Direct3D's Retained Mode, OpenGL operates at a lower level, like Direct3D's Immediate Mode. So nothing like SetRotation is available. But it is not hard to do the equivalent. Just keep track of the current angle of rotation and rotate the sphere with the glRotate command.

[This message has been edited by DFrey (edited 11-06-2000).]

yoda
11-06-2000, 07:17 PM
There is no automatic way to rotate an object indefinately. However if you create a function to increment the angle of rotation say something like:

void keepGoing(void)
{
rotationalValue += 0.5;
glutPostRedisplay();
}

and in your program you call this function using the:

glutIdleFunc(keepGoing);

The object in question will keep rotating providing you have also modified your display to output the rotation.

ie. void display(void)
{...
glRotatef(rotationalValue, x,y,z);
...}

Hope that helps! http://www.opengl.org/discussion_boards/ubb/smile.gif

Cheers!

monson
11-07-2000, 10:19 AM
thanks guys this does help.