/ comp / gb.opengl / gl / viewport
Gl.Viewport (gb.opengl)
Syntax

    STATIC SUB Viewport ( X AS Integer, Y AS Integer, Width AS Integer, Height AS Integer )

### Set the viewport

#### Parameters

- X, Y specify the lower left corner of the viewport rectangle, in pixels. The default is (0, 0).

- Width, Height specify the width and height, respectively, of the viewport. When a GL context is first attached to a window, width and height are set to the dimensions of that window.

#### Description

Gl.Viewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let (xnd, ynd) be normalized device coordinates. Then the window coordinates (xw, yw) are computed as follows:

Viewport width and height are silently clamped to a range that depends on the implementation. This range is queried by calling Gl.MaxViewportDims.

#### Errors

Gl.GL_INVALID_VALUE is generated if either width or height is negative.
Gl.GL_INVALID_OPERATION is generated if Gl.Viewport is executed between the execution of Gl.Begin and the corresponding execution of Gl.End.

#### Associated Gets

Gl.GetViewport
Gl.MaxViewportDims

### See also

Gl.DepthRange