|
Sync | ||
Sync | ||
Parameters: NONE | ||
Returns: NONE | ||
The Sync command displays the graphics that have been drawn to us, without it, we won't see anything ! Sync is required as the screen we created from the OpenScreen command, doesn't just use one image to represent the game screen, there's actually two! These screens shall be known as the Front and Back screens. The Front is the visible version of the screen image, while the Back is a version that your actually drawing to. Once drawing is complete, we then swap (via Sync) the Back and Front images over and start the drawing process again. So the image that we've just completed drawing to, the back screen, becomes visible to us (I.e it becomes the Front screen) while the previous visible image is now hidden to us (it becomes the Back Screen) Those familiar with computer graphics, will no doubt know this as Double Buffering. It's this approach that lets our programs appear to draw smoothly to the monitor, as without it, they would flicker and flash horribly! This is not to be confusing with a graphical glitch called 'tearing' which often occurs when your computers graphics hardware tried to display the Front screen while the Sync is in progress. Which can generally be eliminated via activating ScreenVsync. But will give you slower overall performance. FACTS: * Sync and SwapScreen have identical functionality. Both swap the hidden screens information (back) to the visible screen (front) for you. * Note: Double Buffering behaves differently in Window and Full Screen modes. In a windowed screen mode, the front screen is considered the actual Window. In this case, Rather than swapping Front->Back and Back->Front, the Back Screen image is copied over the Front Screen image. While in full screen modes your graphic card we generally swap the buffers via indirection (a pointer swap), which is the fastest solution, but not all Video cards support this approach. So ome cards work the same in Full Screen mode and windowed. * PlayBASIC uses the Sync process to help the user control the games frame rate, by preventing the game from running too fast if you require. You can set your preferred frame rate using the SetFps command. Mini Tutorial #1: This examples draws 100 random circle graphics, then uses Sync to show us the results...
Mini Tutorial #2 - Basic Computer Animation: This example shows a circle moving across the screen from LEFT to RIGHT. Each time through the Main (DO/LOOP) the program clears the screen to black, Adds one to our XPOS varibale, Renders a Circle using the Xpos variable as it's X coordinate and renders a text message using print. Once we've finished drawing we then call Sync to
|
Related Info: | FPS | GetScreenType | GetScreenVSync | OpenScreen | ScreenVsync | SetFPS | SwapScreen : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |