SwapScreen
SwapScreen
 
Parameters: NONE
Returns: NONE
 

      The SwapScreen command displays the graphics that have been drawn to us. Without it, we won't see anything !

      It's required as the Screen we created from the OpenScreen command, doesn't just use one image to represent the 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 SwapScreen) 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 SwapScreen is in progress. Which can generally be eliminated via activating ScreenVsync. But will give you slower 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 actually Window. In this case, Rather than swapping Front->Back and Back->Front, the Back Screen image is copied over the Front Screen. While in full screen modes your graphic card can swap the buffers via indirection (a pointer swap), which is fastest solution, but not all Video cards support this approach. So some cards work the same in Full Screen mode, as windowed.





Mini Tutorial:


      This examples draws 100 random circle graphics, then uses SwapScreen to show us the results...

  
  
; Draw 100 circles to the BACK screen...
  For lp 1 To 100
     Circle Rnd(100),Rnd(100),50,1
  Next
  
; Display the Screen.. This will copy the BACK Screen to
; the FRONT, so it's visible to the user.
  SwapScreen
  
; Wait for a screen press
  WaitKey
  



 
Related Info: Fps | OpenScreen | SetFps | Sync :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com