3.3 Using a hardware double buffer

If you want your script to benefit from OpenGL's hardware-accelerated drawing functions, you need to use a hardware double buffer and do all your drawing within that double buffer. Using a hardware double buffer will also ensure that graphics output is synchronized with your monitor's refresh rate to prevent any flickering. To get an optimal performance with OpenGL, your main loop should always look like this:

 
@REQUIRE "glgalore"

BeginDoubleBuffer(True)  ; set up a hardware double buffer

Repeat
    ....          ; draw the next frame here
    Flip()        ; wait for vertical refresh, then flip buffers
    CheckEvent()  ; run event callbacks
Forever

The call to CheckEvent() is only necessary if your script needs to listen to event handlers that have been installed using InstallEventHandler(). Note that you should not draw the next frame in an interval callback that runs at a constant frame rate (say 50fps) because such a setup won't guarantee that drawing is synchronized with the vertical refresh as different monitors use different refresh rates so you might get flickery graphics. If you do your drawing like above, you can be sure that front and back buffers will be flipped in perfect synchronization with the monitor's vertical refresh.

Additionally, you need to take care of how you actually draw your graphics because most of Hollywood's drawing commands operate entirely in software mode and thus do not benefit from hardware acceleration. See Drawing graphics for details.

Important: OpenGL is designed to be used with double buffers. Thus, all OpenGL drawing commands must be called within a double buffer. Drawing outside a double buffer with OpenGL is unsupported.


Show TOC