Skip to content

SCREEN (GRAPHICS) ​

Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgScreengraphics Last revised: 2023-07-12

Initializes a graphics mode using QB-like mode numbers.

Syntax ​

-lang fb|fblite dialects:

Screen mode [, [depth] [, [num_pages] [, [flags] [, [refresh_rate]]]]]
Screen , [active_page] [, [visible_page]]

-lang qb dialect:

Screen [mode] [, [colormode] [, [active_page] [, [visible_page]]]]

Parameters ​

  • mode — QB-style screen mode number. If 0, closes the graphics mode and returns to console.
  • depth — Color depth in bits per pixel for modes 14+: 8, 16, or 32 (15 and 24 are aliases for 16 and 32). Default: 8.
  • num_pages — Number of video pages. Default: 1.
  • flags — Graphics driver options; constants defined in fbgfx.bi (see Screenres for details).
  • refresh_rate — Requested refresh rate.
  • active_page — Page where drawing commands take effect.
  • visible_page — Page shown to the user.
  • colormode — Unused; allowed for QB syntax compatibility.

Description ​

Screen links the GfxLib and initializes a graphics mode. QB-like graphics and console statements can be used in QB-only and QB-on-GUI modes.

If Screen fails to set the required mode, an "Illegal function call" error is issued. Failures can be detected using On Error or by checking ScreenPtr.

Available Modes ​

QB compatibility modes:

ModeResolutionEmulationColors
1320×200CGA16 bg, 4 fg
2640×200CGA2 colors
7320×200EGA16 colors
8640×200EGA16 colors
9640×350EGA16 colors
11640×480VGA2 colors
12640×480VGA16 colors
13320×200MCGA256 colors

FreeBASIC extended modes:

ModeResolution
14320×240
15400×300
16512×384
17640×400
18640×480
19800×600
201024×768
211280×1024

Examples ​

vb
' Sets screen mode 13 (320×200, 8bpp)
Screen 13
Print "Screen mode 13 set"
Sleep
vb
#include "fbgfx.bi"
#if __FB_LANG__ = "fb"
Using FB
#endif
' Sets 640×480, 32bpp, 4 pages, windowed, switching disabled
Screen 18, 32, 4, (GFX_WINDOWED Or GFX_NO_SWITCH)
If ScreenPtr = 0 Then
    Print "Error setting video mode!"
    End
End If
Print "Successfully set video mode"
Sleep

Platform Differences ​

  • In DOS, windowing and OpenGL options are not available.

Differences from QB ​

  • None in the -lang qb dialect.
  • In QB, syntax was Screen mode, colormode, active_page, visible_page; FreeBASIC redefines these parameters.
  • Screenset should be used in -lang fb and -lang fblite for page management.

See Also ​

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft