PDA

View Full Version : What do the "matrix mode" and "PortView"variable change



HAMCircuitsWillBearMyName
11-28-2001, 06:23 PM
I am curious as to the real functions of these variables. I have a tutorial but it offers little insight. Could any one please elaborate on this. THANKS!!

JLawson
11-29-2001, 06:18 AM
Are you referring to glMatrixMode(GL_MODELVIEW); and glMatrixMode(GL_PROJECTION); ?

If so, then allow me to explain.

GL_MODELVIEW is the matrix that allows you to edit the objects in your scene.

GL_PROJECTON enables you to edit the matrix that holds the "camera" position, type, and other stuff.

so modelview is for objects, and projection is for camera.

like, if you say
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(1.0, 0.0, 0.0);

you will be moving all your objects 1 unit along the x axis.

If you say
glMatrixMode(GL_PROJECTION);
glLoadIdentiy();
glTranslatef(1.0, 0.0, 0.0);

you will be moving your viewport, camera position, whatever you want to call it, one unit along the x axis.

Hope that helps.

j
11-29-2001, 07:05 AM
A sidenote on this:

Putting your camera position and rotation into the projection matrix will work, but only until you try adding lighting or fog. You will then get incorrect results. You can check out this site to find out why: http://www.sjbaker.org/steve/omniv/projection_abuse.html

Put gluPerspective, gluOrtho2D, glFrustum, and glOrtho into the projection matrix.

Put everything else into the modelview matrix.

j