View Full Version : MatrixMode() - Parameters
What does MODELVIEW and PROJECTION do when sending as parameters to the function MatrixMode()?
03-10-2001, 07:09 PM
OpenGL has states for a few different matrices. There is the Projection matrix, which is used for transforming things such as your view frustum. With this matrix you will usually only do things like glFrustum, glOrtho, or the corresponding glu functions gluPerspective, gluOrtho2d. Then there is the Model-View, which you use to transform the position, rotation, and scale of the objects you will render. Then there is the Texture matrix, which you can use to transform matrix coordinates.
03-10-2001, 07:09 PM
In OGL there are three matrix modes(MODELVIEW,PROJECTION,TEXTURE).
When you call glMatrixMode(XXX), all further matrix operations like glPushMatrix, glMultMatrix, glRotatef will deal with XXX matrix.
MODELVIEW matrix means transformations of objects, it's typically main mode. When in MODELVIEW mode when you call glRotatef, ojects are rotated.
PROJECTION matrix is for projection ;-}. It's typically filled with gluProjection. If you're just rendering models, typiclly there is no need to change it.
03-18-2001, 10:46 AM
Actually, MODELVIEW matrix is usually combinations of rotations/translations. It is used, world space is transformed to camera space. After it, camera is in origin of the scene. PROJECTION matrix puts camera a little further (generically, the SIMPLEST projection) and also does viewing frustum transformation. More help - in OpenGL or D3D(:-]) documentations.
As everything around openGL is about 3D I haven't been able to find an answer to this question: When I'm setting the view using glOrtho2D(), I'm I to use the function glModelView() with the parameter GL_PROJECTION aswell as when I use gluPerspective()?
When you set projection (glOrtho, glFrustum, gluPerspective, gluOrtho2D), you should use the GL_PROJECTION matrix. When transforming objects/viewpoint (glTranslate, glRotate, glScale), you whould use GL_MODELVIEW. Using modelview matrix operations using the projection matrix, or using projection matrix operation using modelview matrix is almost guarateed to screw up reflection, lighting, fogging, and maybe some more stuff.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.