BeginRefresh([force])
BeginRefresh()
will be queued until you call EndRefresh(). By caching all drawing
commands that are called between BeginRefresh()
and EndRefresh(), the
latter will be able to refresh your whole display in a single frame which on many platforms
is the most efficient way of drawing besides using a double buffer. On platforms that don't
support optimized refreshing, calling BeginRefresh()
and EndRefresh()
won't have any effect at all so it is safe to always use it in your scripts and Hollywood
will enable it automatically when needed.
Optimized refreshing is always supported on Windows (except when the software renderer is active), macOS (except on PowerPC), iOS and Android. On all other platforms optimized refreshing is only supported when the auto scaling engine is active. See Scaling engines for details.
To better understand the concept behind optimized refreshing, you need to understand that
on some systems all drawing operations will always result in a complete redraw of the whole
display, even if just a single pixel is changed. Now imagine the following situation:
For every new frame your game has to draw 48 sprites to the screen. On systems that always
refresh the whole display even if just a single pixel has changed this means that Hollywood
has to redraw the whole screen 48 times and this 50 times a second if your game runs at 50fps.
Thus, 2400 complete screen refreshes (48 * 50) would be necessary per second (!). This of
course will significantly kill your game's performance. If you encapsulate the drawing of the 48
sprites inside a BeginRefresh()
and EndRefresh() section instead, Hollywood will
only have to refresh the screen once per frame (50 times per second), which
leads to a much smoother appearance. Thus, using BeginRefresh()
in this case is
absolutely mandatory to ensure a good performance of your game.
Optimized refresh can also greatly enhance the performance of your script when
autoscaling is active. If you use normal drawing with autoscaling, Hollywood will
have to scale its refresh buffer to the desired dimensions on every single command
that draws something. If you use a BeginRefresh()
section here instead, Hollywood
will just have to scale its refresh buffer once EndRefresh()
is called. This of course can also enhance the performance significantly.
By default, BeginRefresh()
will only use optimized refresh if its use is either
encouraged on the host platform or if autoscaling is enabled. You can
change this behaviour by passing True
in the optional force argument. If force
is set to True
, BeginRefresh()
will always use optimized refresh but this is
not recommended because optimized refresh can also be slower than normal refresh
in some cases. That is why you should leave the decision whether to use optimized
refresh or not to Hollywood.
Please note that you only need to use BeginRefresh()
sections if your script
does its drawing without a double buffer. If your script uses a double-buffer,
drawing is already pipelined to one refresh per frame and thus using BeginRefresh()
is not needed in this case.
False
which means leave
the decision to Hollywood)BeginRefresh() For Local k = 1 To 48 DisplaySprite(k, sprites[k].x, sprites[k].y) Next EndRefresh()The code above updates the positions of 48 sprites using a
BeginRefresh()
section.
This means that on systems that always refresh the whole display (e.g. Android)
Hollywood just has to update the screen once to reposition all 48 sprites. Without
BeginRefresh()
Hollywood would have to update the screen 48 times which is of course
much slower.