GLBasic User Manual

Main sections

GETVIEWPORT

GETVIEWPORT x%%, y%%, w%%, h%%



Returns the current viewport position and dimensions.

If you call VIEWPORT 0,0,0,0 (i.e. reset the viewport to 0, 0, screenwidth, screenheight), you can still run GETVIEWPORT without it causing an error, it will return 0, 0, screenwidth, screenheight.

// --------------------------------- //
// Project: Multiple Viewports
// Start: Wednesday, August 11, 2004
// IDE Version: 2.40811

WHILE TRUE
PRINT "Test", 0, 0

MOUSESTATE mx, my, b1, b2
GOSUB Scene // 3D Scene

VIEWPORT mx, my, 150, 100
// Draw more than the viewport's boundaries
DRAWRECT -100, -100, 400, 600, RGB(0, 0, 64)
PRINT "Viewport.....", 0, 0
GETVIEWPORT vx,vy,vw,vh // Returns mx,my,150,100
GOSUB Scene

VIEWPORT 0,0,0,0 // Reset
PRINT "Back to normal", 0, 20
PRINT "Viewport x="+vx+" y="+vy+" width="+vw+" height="+vh,0,40
SHOWSCREEN
WEND

// ------------------------------------------------------------- //
// -=# SCENE #=-
// ------------------------------------------------------------- //
SUB Scene:
X_MAKE3D 1, 100, 45
X_CAMERA 0,0,10, 0,0,0
X_OBJSTART 1
X_OBJADDVERTEX 0, 0, 0, 0,0, RGB(255,255,255)
X_OBJADDVERTEX 1, 1, 0, 1,1, RGB(255,255,255)
X_OBJADDVERTEX 0, 1, 0, 0,1, RGB(255,255,255)
X_OBJEND
X_ROTATION GETTIMERALL()/30, 0, 1, 0
X_DRAWOBJ 1, 0
X_DRAWAXES 0,0,0
ENDSUB // SCENE

See also...