View Full Version : modelview/ projection

I saw many reshape functions...but i still don't understand when to use projection and when to use modelview. There has to be some logic behind this.

glMatrixMode (GL_PROJECTION)

glMatrixMode(GL_MODELVIEW)

Could someone explain how the two differ.

Thanks

Deiussum

09-25-2002, 11:12 AM

The projection matrix basically defines the shape of the area that is viewable. If a point is visible in the viewable area, after being multiplied by the projection matrix it will be essentially be inside a 1x1x1 cube. In this way, OpenGL can quickly determine if it's visible and if so can then go to the next step of clipping to the viewport. The ONLY matrix functions that should typically be used when the projection matrix is current are methods like glLoadIdentity, glFrustum, glOrtho, gluPerspective, and gluOrtho2D. If you are going to use anything else on the projection matrix, you should know and understand what you are doing first.

The modelview matrix is generally used to move things around the scene. Pretty much all of the other matrix methods are used here. glLoadIdentity, glTranslate, glRotate, glScale, gluLookAt, etc.

You can also use glLoadMatrix and glMultMatrix for either of those matrices, but again, you typically should know what you are doing in the first place if you use those methods.

nexusone

09-25-2002, 12:44 PM

It really is as simple as it sounds.

Projection: Think of your monitor as a movie screen, and projection is how the image is projected to it. You make lens settings, and distance from your objects, etc. You put thing here that effects your view of the scene.

Modelview: What is a model? It is a replica of a real objects, like people, cars, etc.

Our models are positioned and constructed under modelview.

Another good example of the two is like taking a picture of something.

You setup your camera(projection) on a tripod a then focus on the object that your photographing. You also will arrange your objects(model) so that you can get the right arrangement for your shoot.

Originally posted by lara:

I saw many reshape functions...but i still don't understand when to use projection and when to use modelview. There has to be some logic behind this.

glMatrixMode (GL_PROJECTION)

glMatrixMode(GL_MODELVIEW)

Could someone explain how the two differ.

Thanks

[This message has been edited by nexusone (edited 09-25-2002).]

Deiussum

09-25-2002, 02:07 PM

Just wanted to clarify a bit what nexusone said. The projection matrix basically handles camera properties as he said. It would be more or less like the properties of the lens. How big the field of view is, etc.

It should not be used to position the camera however. That part is where the "view" of "modelview" comes in. Trying to use something like gluLookAt or glTranslate to move the camera around in the projection matrix can mess up calculations for lighting and fog, giving you unexpected results. Usually these are the first things applied to the modelview matrix after glLoadIdentity.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.