3.4 Using hardware brushes

RebelSDL supports the creation of hardware brushes. Hardware brushes reside in GPU memory and thus can be drawn in no time. On most graphics boards, they can also be scaled and transformed by the GPU in an extremely efficient way. To make Hollywood create a hardware brush, all you have to do is set the optional Hardware tag to True. This tag is supported by most of the Hollywood commands which create brushes.

Here is an example:

 
@REQUIRE "rebelsdl"  ; make sure this line is first
@BRUSH 1, "sprites.png", {Hardware = True}

In the code above, RebelSDL will create brush 1 in video memory. It can then be drawn using the GPU at almost no cost. Keep in mind, though, that hardware brushes can only be drawn to hardware double buffers. See Using a hardware double buffer for details.

To transform a hardware brush, you can use the ScaleBrush(), RotateBrush(), and TransformBrush() commands. Transformations of hardware brushes are usually also GPU-accelerated and thus many times faster than transformations done by the CPU.

Note that hardware brushes can only be drawn to the display that was specified when allocating them. Thus, if your script uses multiple displays, you need to tell Hollywood the identifier of the display you want to use this hardware brush with. This can be done by specifying the "Display" tag along the "Hardware" tag. Here is an example:

 
@REQUIRE "rebelsdl"  ; make sure this line is first
@DISPLAY 1, {Title = "First display"}
@DISPLAY 2, {Title = "Second display"}
@BRUSH 1, "sprites.png", {Hardware = True, Display = 1}
@BRUSH 2, "sprites.png", {Hardware = True, Display = 2}

The code above will allocate brush 1 in a way that it can be drawn to display 1 and it will allocate brush 2 in a way that it can be drawn to display 2. It won't be possible, however, to draw brush 2 to display 1 or brush 1 to display 2! RebelSDL hardware brushes are always display-dependent and can only be drawn to the display they were allocated for.

Please see the Hollywood manual for more information on hardware brushes and hardware double buffers.

You can also use RebelSDL as a helper plugin to add hardware brush support to Hollywood on Windows, macOS, and Linux. By default, Hollywood doesn't support hardware brushes on these systems but RebelSDL can add this feature to Hollywood. See RebelSDL as a helper plugin for details.

The SmoothScroll.hws example script that comes with RebelSDL demonstrates how to use hardware brushes and a hardware double buffer to achieve butter-smooth scrolling that is fully synchronized with the monitor's vertical refresh.


Show TOC