GLBasic User Manual

Main sections


CREATESCREEN id_screen%, id_sprite%, w%, h%

Creates a virtual, hidden screen. When you draw on this screen, the output will be drawn on sprite id_sprite%. Thus, you can very rapidly draw to a texture by creating a screen that points to a texture image.
The screen and sprite will have the dimensions w% x h% (width x height).

id_screen% must be one of the 32 virtual screens and thus must be in the range of 0 to 31. Screen -1 is the back buffer.

w% and h% must be at least 8 pixels. To make one (or both) of the dimensions smaller than 8 pixels you will need to set it to 8 pixels and fill the remainder with the transparent color.

GLBasic uses the OpenGL extension GL_EXT_framebuffer_object for real OpenGL implementations. This extension can cause trouble on some (generally rather old) systems. In this instance, GLBasic will still provide the CREATESCREEN functionality however it may become slow and the screen size might be limited to the physical window size.

Use PLATFORMINFO$("GLEX:glBindFramebufferEXT") to check whether your card supports the fast version - it will return 1 if it is supported.

In order to free a screen, call CREATESCREEN with width,height=0 or id_sprite<0.

PRINT "Monitor", 0,0
GRABSPRITE 1, 0,0,32,32

// Screen 0, Sprite 13
CREATESCREEN 0, 13, 128,128
// Use screen for all output
PRINT "Offscreen", 0,0
// Switch back to the window

// Draw the screen
DRAWSPRITE 13, 100,100

See also...