OpenScreen
OpenScreen Width, Height, Depth, Type
 
Parameters:

    Width = The Width of the Screen Mode in Pixels
    Height = The Height of the Screen Mode in Pixels
    Depth = The Number of colours to use for this screen mode (16,24,32 bit)
    Type = The Display Type that you wish to use (None, Windowed, Full Screen)
Returns: NONE
 

      There are a couple of ways to initial the size and number of colours the PlayBASIC screen will use. The preferred approach is via the project settings window from the IDE. If you look under Projects->Settings->Screens you'll find that each project has it's own default display mode. You may already noticed that when you run a PlayBASIC program it magically creates the default screen for you, this is how that's done. But there are times when you'll no doubt wish to set up the screen mode yourself (like when implementing a screen mode selector), for which you would use OpenScreen command.

      OpenScreen attempts to initialize the display mode your program will use. When you open the screen, PlayBASIC requires the dimensions (width & height) and the number of colours you wish to use. As a guide, the bigger the screen size (higher the resolution) you select, the more computer horse power that will be needed to update the display smoothly.

      There are two main types of displays that OpenScreen can create, Windowed and Full Screen mode. In Windowed mode, the PB screen will appear like any other windows application, while in full screen mode the display will be the full size of the monitor.


Common Full Screen Modes

640x,480y
800x,600y (pb's default)
1024x,768y


Depth (number of colours)

16 = 65536 colours
24 = 16.8 Million colours
32 = 16.8 Million colours


Warning Many newer video cards do not support 24bit screen depths.


Available Screen Types

0 = No Display (not presently supported)
1 = Run Program in a window
2 = Full Screen Mode



Screen Layout:


     The screen is made of a grid of dots/pixels in a 2D array. To locate dots on the screen via the X axis and Y axis. The X axis refers to Left/Right across the screen and the Y Axis is UP/DOWN. The top left hand corner of the screen, is the 0x,0y coordinate (Shown Bellow). Which might surprise those from a graphing background, but it's pretty common in computer programming. If you're wondering why it's to do with how memory that maps the screen/image is laid out.




Note: Screen Shot Taken On Windows XP, Others may differ)


     So if had a screen that's 800 wide, by 600 high and wanted to draw a line across the top of the screen, we'd use something like.

  
;  draw line from 0x,0y, to 800x,0y
  Line 0,0800,0
  


      Now to draw a line across the bottom we might use something line Line 0,599,800,599, we're using 599 since coordinates are zero inclusive. So a screen width of 800, gives us a legal coordinates from 0 - 799, giving us a complete 800 pixels range. Same for the Y axis.





FACTS:



* By default, OpenScreen with automatically center the display when in windowed mode for you.

* Full Screen mode requires that you provide screen dimensions that are legal for the computers video card. It's good programming behavior to always test if the screen mode exists (using ScreenModeExist) before trying to open it. Don't assume that just because your computer has a particular screen mode, that everybody else does also.


* Using OpenScreen within a programs can delete any previously load image media from memory.. Therefore, It's best to open the screen you wish to use at the start of your program, then leave it.

* By default, the PB Screen is Double buffered. This means that screen is actually made up of two images. So it contains the visible image (also know as the front buffer) and a second hidden image (back buffer) we can't. All drawing occurs on the hidden image (Back buffer). We then use Sync to swap the buffers. (Hidden Becomes visible, Visible becomes hidden). This approach is th back bone of computer animation and ensure the player doesn't 'see' the rendering while it occurring. If you did, you'd sea flashing mess.








Mini Tutorial #1:


This example attempts to open a Windowed Screen of 600,400 in 16 bit mode.

  
; Open a 600x by 400y screen in 16bit mode (windowed)
  OpenScreen 600,400,16,1
  
; Display info about this display mode
  Print "The Screens Current Settings are."
  Print "Current Display Width:"+Str$(GetScreenWidth())
  Print "Current Display Height:"+Str$(GetScreenHeight())
  Print "Current Display Depth:"+Str$(GetScreenDepth())
  Print "Current Display Type:"+Str$(GetScreenType())
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  



Note: Since it's running windowed mode, it might not have a screen depth of 16.





Mini Tutorial #2:


Making the screen use Full Screen mode 1024,768 in 32 bit mode.

  
  
; Open a 1024x by 768y screen in 32bit mode (Full Screen)
  OpenScreen 1024,768,32,2
  
; Display info about this display mode
  Print "The Screens Current Settings are."
  Print "Current Display Width:"+Str$(GetScreenWidth())
  Print "Current Display Height:"+Str$(GetScreenHeight())
  Print "Current Display Depth:"+Str$(GetScreenDepth())
  Print "Current Display Type:"+Str$(GetScreenType())
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  






 
Related Info: CloseScreen | GetScreenHeight | GetScreenType | GetScreenWidth | ScreenModeExist :
 


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