glViewport

set the viewport

Signature

glViewport( GLint ( x ) , GLint ( y ) , GLsizei ( width ) , GLsizei ( height ) )-> void
glViewport( x , y , width , height )

Parameters

VariablesDescription
x, y
Specify the lower left corner of the viewport rectangle, in pixels. The initial value is (0,0).
width, height
Specify the width and height 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

glViewport specifies the affine transformation of x and y from normalized device coordinates to window coordinates. Let x nd y nd be normalized device coordinates. Then the window coordinates x w y w are computed as follows:
x w = x nd + 1 width 2 + x
y w = y nd + 1 height 2 + y
Viewport width and height are silently clamped to a range that depends on the implementation. To query this range, call glGet with argument GL_MAX_VIEWPORT_DIMS .

Errors

GL_INVALID_VALUE is generated if either width or height is negative.

Associated Gets

glGet with argument GL_VIEWPORT
glGet with argument GL_MAX_VIEWPORT_DIMS

Version Support

glViewport

See Also

Copyright

Copyright
1991-2006 Silicon Graphics, Inc. Copyright
2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see .

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glViewport
OpenGLContext OpenGLContext/context.py Lines: 645
OpenGLContext tests/shadow_1.py Lines: 550
OpenGLContext tests/shadow_2.py Lines: 135
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson11.py Lines: 65
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 135
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 104
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 208
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 69
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 84
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson5.py Lines: 82
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson4.py Lines: 79
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 85
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson12.py Lines: 61
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson3.py Lines: 69
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson13.py Lines: 128
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson1.py Lines: 69
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 133
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 265, 273, 281, 289, 356
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson2.py Lines: 69
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 139
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 358
OpenGL-Demo PyOpenGL-Demo/da/dots.py Lines: 93
OpenGL-Demo PyOpenGL-Demo/GLUT/gears.py Lines: 211
OpenGL-Demo PyOpenGL-Demo/GLUT/shader_test.py Lines: 72
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/conechecker.py Lines: 35, 39, 41
OpenGL-Demo PyOpenGL-Demo/redbook/scene.py Lines: 110
OpenGL-Demo PyOpenGL-Demo/redbook/drawf.py Lines: 90
OpenGL-Demo PyOpenGL-Demo/redbook/lines.py Lines: 124
OpenGL-Demo PyOpenGL-Demo/redbook/movelight.py Lines: 114
OpenGL-Demo PyOpenGL-Demo/redbook/smooth.py Lines: 85
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 115
OpenGL-Demo PyOpenGL-Demo/redbook/double.py Lines: 87
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 183
OpenGL-Demo PyOpenGL-Demo/redbook/cube.py Lines: 79
OpenGL-Demo py2exe-example/shader_test.py Lines: 73
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 160
{Artistic License} PymmLib pymmlib/mmLib/OpenGLDriver.py Lines: 142
{LGPL} PyUI2 renderers/openglGlut.py Lines: 229
{LGPL} PyUI2 system/glutdevice.py Lines: 170
{LGPL} VisionEgg VisionEgg/Core.py Lines: 1362
{LGPL} PyMT examples/apps/3Dviewer/3Dviewer.py Lines: 38
{LGPL} PyMT pymt/ui/window/__init__.py Lines: 19, 451
{LGPL} PyMT pymt/graphx/fbo.py Lines: 20, 224, 261
{LGPL} Pyggel pyggel/view.py Lines: 301
{LGPL} Pyggel pyggel/data.py Lines: 550, 612
{GPL} Scocca scocca/graphics/opengl/viewport.py Lines: 22
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Cubes.py Lines: 54
{LGPL or GPL or MPL} Kamaelia Sketches/CL/Topology3D/Experiments/Spheres.py Lines: 38
Gloopy gloopy/view/projection.py Lines: 27
OpenGL Tutorial (Python Translation) t02.playing-with-colors/FragPosition.py Lines: 98
OpenGL Tutorial (Python Translation) t02.playing-with-colors/VertexColors.py Lines: 104
OpenGL Tutorial (Python Translation) t01.hello-triangle/HelloTriangle.py Lines: 115
Visvis core/baseFigure.py Lines: 309
{GPL3} OpenGL-Programmable 05-shader.py Lines: 212
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 231
{GPL3} OpenGL-Programmable 03-array.py Lines: 127
{GPL3} OpenGL-Programmable 09-gles2.py Lines: 275
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 220
{GPL3} OpenGL-Programmable 10-gl3.2core.py Lines: 285
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 125
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 146
{GPL3} OpenGL-Programmable 01-direct.py Lines: 116
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 253

MathML Rendering

Powered by MathJax