The glViewport function sets the viewport.
void glViewport(
GLint x,
GLint y,
GLsizei width,
GLsizei height
);
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:
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:
glGet with argument GL_VIEWPORT
glGet with argument GL_MAX_VIEWPORT_DIMS
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. |
Windows NT: Use version 3.5 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in gl.h.
Import Library: Link with opengl32.lib.