GLBasic User Manual

Main sections

PRESCALER

PRESCALER screenx%, screeny%



This command offers the posibility to scale all graphics output, as if the output screen was of the dimensions screenx% X screeny% pixels. This helps porting existing programs for handhelds to e.g. Android and iOS.
The scaling is done using factors: 1, 1.5, 2,3,4,8,10 and all integer numbers above.
The scaling won't be reduced to < 1.0.

Afterwards, the image is getting centered. The remaining frame can be coloured with CLEARSCREEN. This command only is available on OpenGL-based platforms.

ATTENTION:
The following commands currently do NOT work with the prescaler:
LOADBMP
SAVEBMP
GRABSPRITE

SYSTEMPOINTER TRUE

LOCAL pix%[]
DIMDATA pix%[], 0xff00ffff, 0xff00ff00, 0xff0000ff, 0xffff0000
MEM2SPRITE(pix[], 0, 2,2)

PRESCALER 320,240 // GRABSRITE will not work in scaled mode!!
SMOOTHSHADING FALSE


CREATESCREEN 4,4,64,64
USESCREEN 4
DRAWRECT 0,7,64,10,RGB(0,255,128)
PRINT "Screen#4", 0,8
USESCREEN -1


LOCAL scx,scy
GETSCREENSIZE scx,scy
WHILE TRUE

    VIEWPORT 0,0,0,0

    LOCAL x,y,b1,b2
    MOUSESTATE x,y,b1,b2

    DRAWRECT 0,0,scx,scy, RGB(0,0,64)

    DRAWRECT 0,y,scx,1,0xffffff
    DRAWRECT x,0,1,scy,0xffffff

    STRETCHSPRITE 0,x,y, 16, 16
    PRINT "P",x,y

    VIEWPORT 100,100,64,64
    DRAWRECT -999,-999,2222,2222,RGB(0,0,128)
    PRINT "Viewport", 0,0
    VIEWPORT 0,0,0,0


    PRINT scx+"/"+scy, 0,0
    PRINT x+", "+y, 0,32

    DRAWSPRITE 4,100,164

    SHOWSCREEN
    HIBERNATE
WEND

See also...