If you want your script to benefit from RebelSDL'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 RebelSDL, your main loop should always look like this:
@REQUIRE "rebelsdl" 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.
When drawing brushes in a hardware double buffer, make sure that you use only hardware brushes because only those can be drawn directly using hardware acceleration. Drawing normal brushes to hardware double buffers is possible too, but it will be very slow. See Hardware brushes for details.
Important: SDL is designed to be used with double buffers. Thus, you can only benefit from hardware acceleration when drawing within a double buffer. Drawing outside a double buffer is possible but it will be much slower.