PDA

View Full Version : What controls the rendering frequency in OpenGL?



galaxy3001
03-11-2003, 06:47 AM
In a simple OpenGL program that rotates a triangle on the screen, the rendering is usually done in a while loop, each time the loop is executed the orientation of the triangle is increased by 0.1 degree (set back to 0.0 if exceeds 360.0). But nowhere in the program does it mention the time interval that separates two successive renderings.

What controls the rendering frequency (or equivalently the rotational speed) of the triangle?

Thanks for help.

nexusone
03-11-2003, 10:02 AM
OpenGL just does the drawing of the scene, you have to control when the scene is updated in your own code.

The rendering will vary based on complexity of the scene and hardware doing the rendering.

In a simple loop the frequency will be based on above factors. Since the very little time is use to increase the variable in the loop.

Some code uses a timming loop, after X time calls the rendering routine to update the scene. This type of loop would be used to control speed of the object.

What does simple program use glut, or window code?


Originally posted by galaxy3001:
In a simple OpenGL program that rotates a triangle on the screen, the rendering is usually done in a while loop, each time the loop is executed the orientation of the triangle is increased by 0.1 degree (set back to 0.0 if exceeds 360.0). But nowhere in the program does it mention the time interval that separates two successive renderings.

What controls the rendering frequency (or equivalently the rotational speed) of the triangle?

Thanks for help.

galaxy3001
03-11-2003, 10:19 AM
The program uses windows code, it is the first OpenGL example in the book "OpenGL Game Programming", it doesn't have a timming while loop.


Originally posted by nexusone:

What does simple program use glut, or window code?

nexusone
03-11-2003, 10:57 AM
In a full program you would have a loop something like this.

// Loop until told to exit
control_loop()
{
// System event could be keyboard press/mouse movement/etc
if (system_event == TRUE ) process_win_event();
// Process object if position has changed, could be from input from above or some other event like AI
if (object_moved == TRUE ) object_handler();
// We need only redraw the screen if the scene has changed
if (scene_change == TRUE ) render_scene();

if (Close_program == TRUE ) exit;
}

http://www.opengl.org/discussion_boards/ubb/smile.gif

Originally posted by galaxy3001:
The program uses windows code, it is the first OpenGL example in the book "OpenGL Game Programming", it doesn't have a timming while loop.