[ Previous | Next | Contents | Glossary | Home | Search ]
OpenGL 1.1 for AIX: Reference Manual

glViewport Subroutine


Sets the viewport.


OpenGL C bindings library: libGL.a

C Syntax

void glViewport(GLint X,
   GLint Y, 
   GLsizei Width,
   GLsizei Height)


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.


The glViewport subroutine 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 the glGet subroutine with the GL_MAX_VIEWPORT_DIMS argument.


GL_INVALID_VALUE Width or Height is negative.
GL_INVALID_OPERATION The glViewport subroutine is called between a call to glBegin and the corresponding call to glEnd.

Associated Gets

Associated gets for the glViewport subroutine are as follows. (See the glGet subroutine for more information.)

glGet with argument GL_VIEWPORT

glGet with argument GL_MAX_VIEWPORT_DIMS.


/usr/include/GL/gl.h Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL.

Related Information

The glBegin or glEnd subroutine, glDepthRange subroutine.

OpenGL Overview.

[ Previous | Next | Contents | Glossary | Home | Search ]