glViewport Function

Syntax

GL_APICALL void GL_APIENTRY glViewport(
     GLint x,
     GLint y,
     GLsizei width,
     GLsizei height
);

Arguments

Name Description
in x X coordinate of the viewport's lower-left corner
in y Y coordinate of the viewport's lower-left corner
in width Viewport width
in height Viewport height

Return Values

No values are returned.

Description

Configures the viewport.

Set x to the x coordinate of the viewport's lower-left corner. Set y to the y coordinate of the viewport's lower-left corner. Unlike in the OpenGL ES 2.0 standard, x and y must be no less than 0. The values of x and y affect rendering performance. Performance degrades when x and y are not multiples of 4. Specifically, performance drops to approximately one-half for any multiple of 2 that is not a multiple of 4, and drops to approximately one-third for odd numbers. We recommend that you adjust for this using the frustum for perspective projection transformations and that you exclude unnecessary areas via scissoring in order to set x and y to multiples of 4 and thus avoid performance degradation.

Set width to the viewport width.

Set height to the viewport height.

This function generates the following errors.

GL_INVALID_VALUEThe x, y, width, or height argument was set to a negative value.
GL_INVALID_OPERATIONThis function was called without any command-list objects bound.

Revision History

2010/01/07
Initial version.

CONFIDENTIAL