tags:

views:

336

answers:

2

GL_PROJECTION and GL_MODELVIEW.

I know there are others, but I, conceptually, can't figure out what the difference between any of them are. When you load the identity matrix after setting the mode, how is the identity matrix any different based on the mode?

A: 

One could say that the GL_PROJECTION is for setting up the camera as what it's like, wide lens etc and one could say that GL_MODELVIEW is for setting up the object that is to be drawn, like size and place in space etc.

To position the camera look at the gluLookAt function...

epatel
"GL_PROJECTION is for setting up the camera. **Where** it is" This is called "OpenGL matrix abuse": "when someone does go and put their camera transform into the GL_PROJECTION matrix (instead of into GL_MODELVIEW where it belongs)", search for it.
Slava N
Yeah you are right. I'll remove that part. I just wanted to write the *novis* way to *think* about the two stacks. I've been coding OpenGL for 10+ years and think it's a journey...
epatel
+2  A: 

The matrix modes do not change the matrix itself, so identity matrix is identity matrix everywhere.

The matrix modes change which matrix the following commands operate on. That is, whether any subsequent commands work with the projection matrix, or with model*view matrix, or with texture matrices etc.

This might sound a bit confusing, but it's one of OpenGL's design decisions - there's a bunch of commands that operate on some state or object, and only other state settings determine which object exactly they operate on.

NeARAZ