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(seeScreenresfor 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:
| Mode | Resolution | Emulation | Colors |
|---|---|---|---|
| 1 | 320×200 | CGA | 16 bg, 4 fg |
| 2 | 640×200 | CGA | 2 colors |
| 7 | 320×200 | EGA | 16 colors |
| 8 | 640×200 | EGA | 16 colors |
| 9 | 640×350 | EGA | 16 colors |
| 11 | 640×480 | VGA | 2 colors |
| 12 | 640×480 | VGA | 16 colors |
| 13 | 320×200 | MCGA | 256 colors |
FreeBASIC extended modes:
| Mode | Resolution |
|---|---|
| 14 | 320×240 |
| 15 | 400×300 |
| 16 | 512×384 |
| 17 | 640×400 |
| 18 | 640×480 |
| 19 | 800×600 |
| 20 | 1024×768 |
| 21 | 1280×1024 |
Examples
vb
' Sets screen mode 13 (320×200, 8bpp)
Screen 13
Print "Screen mode 13 set"
Sleepvb
#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"
SleepPlatform Differences
- In DOS, windowing and OpenGL options are not available.
Differences from QB
- None in the
-lang qbdialect. - In QB, syntax was
Screen mode, colormode, active_page, visible_page; FreeBASIC redefines these parameters. Screensetshould be used in-lang fband-lang fblitefor page management.