SCREENRES
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgScreenres
- Last revised: 2024-04-06
SCREENRES — Initialize a graphics mode
Syntax
Statement form:
vb
Screenres width, height [, [depth] [, [num_pages] [, [flags] [, refresh_rate] ] ] ]Function form:
vb
result = Screenres( width, height [, [depth] [, [num_pages] [, [flags] [, refresh_rate] ] ] ] )Parameters
| Parameter | Type | Description |
|---|---|---|
width | Long | Horizontal resolution (display width in pixels) |
height | Long | Vertical resolution (display height in pixels) |
depth | Long | Color depth in bits-per-pixel. Default = 8. Valid values: 1, 2, 4, 8, 16, 32 (15 treated as 16; 24 treated as 32) |
num_pages | Long | Number of video pages. Default = 1 |
flags | Long | Screen attribute flags. Default = 0 |
refresh_rate | Long | Refresh rate (fullscreen mode only). Default = 0 |
Return Value
- On success: returns
0 - On failure: returns a non-zero error code (a runtime error is also thrown)
Flags
Graphics mode flags
| Flag | Description |
|---|---|
GFX_NULL | Starts QB-on-GUI graphics mode: creates a graphics buffer but no window |
GFX_OPENGL | Initializes OpenGL mode (only OpenGL commands may be used) |
| (none) | Enters QB-only graphics mode (default) |
Window mode flags
| Flag | Description |
|---|---|
GFX_WINDOWED | Windowed mode (default) |
GFX_FULLSCREEN | Fullscreen mode |
GFX_NO_SWITCH | Disables Alt+Enter toggle between fullscreen/windowed |
GFX_NO_FRAME | Creates a borderless window |
GFX_SHAPED_WINDOW | Creates a shaped/transparent window (RGBA(255,0,255,0) = transparent) |
GFX_ALWAYS_ON_TOP | Window is always on top of other windows |
Option flags
| Flag | Description |
|---|---|
GFX_ALPHA_PRIMITIVES | Enables alpha channel support for all drawing primitives |
GFX_HIGH_PRIORITY | Enables higher priority graphics processing |
GFX_NO_X86_MMX | Disables MMX blitters (x86 platforms, since fbc 1.20.0) |
OpenGL buffer flags (used only with GFX_OPENGL)
| Flag | Description |
|---|---|
GFX_STENCIL_BUFFER | Use a stencil buffer |
GFX_ACCUMULATION_BUFFER | Use an accumulation buffer |
GFX_MULTISAMPLE | Request full-scene antialiasing |
Description
Screenres initializes a graphics mode. Three modes are supported:
- QB-compatible graphics mode — windowed or fullscreen. Standard FreeBASIC graphics commands work as expected.
- QB-on-GUI mode (
GFX_NULL) — the user manages the window and refreshing manually. A graphics buffer is created but no window is shown. - OpenGL mode (
GFX_OPENGL) — provides a portable way to initialize OpenGL. Only OpenGL commands should be used; FreeBASIC graphics primitives are not available.
The default font is 8×8 pixels. The Width function can be used to adjust the number of text rows and columns. Console commands such as Locate and Print work in graphics mode.
Example
vb
' Set a 320x200 resolution with 8-bit color depth
ScreenRes 320, 200, 8
' Draw a colored diagonal pattern
For y As Long = 0 To 200 - 1
For x As Long = 0 To 320 - 1
PSet (x, y), (x + y) And 255
Next x
Next y
' Display text in the upper-left corner
Print "Hello world!!"
' Wait for a key press
SleepPlatform Differences
- Windowed mode and OpenGL flags are not supported under DOS.
See Also
- KeyPgScreengraphics —
Screen(Graphics): QB-style graphics mode initialization - KeyPgScreenlist —
Screenlist: query available display modes - KeyPgScreencontrol —
Screencontrol: select driver, etc. - KeyPgScreenptr —
Screenptr: semi-low-level framebuffer access