Refreshing the screen

When visual objects are created, moved, and destroyed, there is screen damage. That damage gets repaired through a two-step process:

  1. The off-screen image buffer is redrawn.
    This is done through a single member function.
    See TRefreshThread::HandleIntervalPassed.

  2. The view is updated from the buffer.
    This multistep process is handled by Concurrent Actors's Refresh, Game, and Interface subsystems with help from the Notification framework.
    See the following sections on sending refresh notification and updating the view from the buffer.

Sending refresh notification

After the refresh thread redraws the buffer, it sends a synchronous notification announcing that a buffer has been redrawn. The TSimulationLevel object receives the notification, adds information on which buffer needs to be redrawn, and sends out a second synchronous notification. (This design allows for extending the program to handle multiple refresh threads and buffers.) The model receives the notification and sends out an asynchronous notification, which gets picked up by the view. This third notification uses the Presentation framework's built-in notification mechanism for model-view notification.

For information on the Notification framework, see Desktop Frameworks Concepts.


The program doesn't require notification--which is meant for broadcasting to multiple receivers--because buffer updates are received by only one view. However, to add multiple views to the program (such as a radar view to see incoming asteroids), notification is ideal. Building in this flexibility is smart and has minimal effect on performance.

Updating the view from the buffer

When the view receives the refresh notification, it draws the buffer to the screen. To guarantee that the image doesn't change before the draw operation can complete, the view lets the model know when it wants to draw and when it has finished drawing. The model blocks the refresh thread appropriately.

NOTE The view draws the entire buffer to the screen. Drawing the entire buffer is quicker than drawing only the damaged area.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker