To main page | 3dengine.org
Main OpenGL Matrices
Three main OpenGL matrices are: GL_PROJECTION (
projection matrix), GL_MODELVIEW (
modelview matrix) and GL_VIEWPORT (
viewport matrix). Although the last one isn't really a matrix, rather a vector (array) of four elements.
Projection matrix defines how big is the
angle of view, what is the
aspect ratio and
clipping ranges.
Modelview matrix defines where the camera is and where the object is (oversimplification).
Viewport matrix defines range
screen space coordinates, except for z coordinate.
PyOpenGL
Getting those:
view = glGetInteger(GL_VIEWPORT)
proj = glGetDoublev(GL_PROJECTION_MATRIX)
model = glGetDoublev(GL_MODELVIEW_MATRIX)
Setting those:
glViewport(*view)
glMatrixMode(GL_PROJECTION)
glLoadMatrixd(proj)
glMatrixMode(GL_MODELVIEW)
glLoadMatrixd(model)
C++
Getting those:
GLdouble buffer[16];
glGetDoublev(GL_PROJECTION_MATRIX, buffer);
GLdouble buffer[16];
glGetDoublev(GL_MODELVIEW_MATRIX, buffer);
GLuint view[4];
glGetIntegerv(GL_VIEWPORT, buffer);