glViewport  1N44DED

[New - Windows 95, OEM Service Release 2]

The glViewport function sets the viewport.

void glViewport(

    GLint x,

 

    GLint y,

 

    GLsizei width,

 

    GLsizei height

 

   );

 

 

Parameters

x, y

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

width, height

The width and height, respectively, of the viewport. When an OpenGL context is first attached to a window, width and height are set to the dimensions of that window.

 

Remarks

The glViewport function specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let (x (nd) , y (nd) ) be normalized device coordinates. The window coordinates (x (w) , y (w) ) are then computed as follows:

{bml bm63.BMP}

Viewport width and height are silently clamped to a range that depends on the implementation. This range is queried by calling glGet with argument GL_MAX_VIEWPORT_DIMS.

The following functions retrieve information related to glViewport:

glGet8KNKTW with argument GL_VIEWPORT

glGet with argument GL_MAX_VIEWPORT_DIMS

 

Error Codes

The following are the error codes generated and their conditions.

Error Code

Condition

GL_INVALID_VALUE

Either width or height was negative.

GL_INVALID_OPERATION

glViewport was called between a call to glBegin and the corresponding call to glEnd.

 

See Also

glBegin, glDepthRange