Page 64 OpenGL Super Bible! // Set function (Multiple domain web hosting)

Page 64 OpenGL Super Bible! // Set function to call when program is idle auxIdleFunc(IdleFunction); // Start main loop auxMainLoop(RenderScene); } The animation produced by this example is very poor, even on very fast hardware. Because the window is being cleared each time before drawing the square, it flickers the entire time it s moving about, and you can easily see the square actually being drawn as two triangles. To produce smoother animation, you need to employ a feature known as double buffering. Double Buffering One of the most important features of any graphics packages is support for double buffering. This feature allows you to execute your drawing code while rendering to an off-screen buffer. Then a swap command places your drawing on screen instantly. Double buffering can serve two purposes. The first is that some complex drawings may take a long time to draw and you may not want each step of the image composition to be visible. Using double buffering, you can compose an image and display it only after it is complete. The user never sees a partial image; only after the entire image is ready is it blasted to the screen. A second use for double buffering is for animation. Each frame is drawn in the off-screen buffer and then swapped quickly to the screen when ready. The AUX library supports double-buffered windows. We need to make only two changes to the bounce.c program to produce a much smoother animation. First, change the line in main() that initializes the display mode to indicate that it should use double buffering: auxInitDisplayMode(AUX_DOUBLE | AUX_RGBA); This will cause all the drawing code to render in an off-screen buffer. Next, add a single line to the end of the Render() function: auxSwapBuffers(); The auxSwapBuffers() function causes the off-screen buffer used for drawing to be swapped to the screen. (The complete code for this is in the BOUNCE2 example on the CD.) This produces a very smooth animation of the red square bouncing around inside the window. See Figure 3-11.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision professional web hosting services

Leave a Reply