To main page |

Viewport matrix

Viewport matrix is 1 by 4 matrix, used in OpenGL like so:
[x, y, width, height]
x,y specify coordinates of lower-left point on user's screen, usually x=0, y=0.

width and height specify inner width and height of OpenGL window.

Is it a matrix ?

Well, it isn't a matrix per se, more like 4 integers, because most of the code I've seen actually uses usual math, rather than matrix math, when dealing with the viewport data.


It is usually set by


It can be get back by
glGetIntegerv(GL_VIEWPORT, ar)
ar is reference to array of 4 elements (x,y,width,height).

In PyOpengl the call would be


Note that this matrix is set and read in integers.

See also

Center of viewport