Sign in to follow this  


Recommended Posts

I'm not really understand what do the 1)MatrixMode and Projection Matrix 2)MODELVIEW and modelview matrix
glViewport(0,0,width,height);						// Reset The Current Viewport

	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix
	glLoadIdentity();									// Reset The Projection Matrix

	// Calculate The Aspect Ratio Of The Window

	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix


Share this post

Link to post
Share on other sites
The projection matrix basically determines what the point of view looks like (similar to your eyes), while the modelview matrix determines what everything looks like (like the world around you). Setting the matrix mode simply switches between these two, and the changes you make to them (translating, rotating, etc.) determine how everything looks when rendered. Hopefully that answers your question.

Share this post

Link to post
Share on other sites
You can liken the modelview and projection matrices as tripods since, like with matrices, a tripod you can move around and rotate whatever that's attached to it, effectively being able to freely position it somewhere inside a room. Of course unlike a tripod, with a matrix you can also scale and shear whatever it's "attached" to. It's not a perfect analogy [smile].

So, imagine that the viewpoint, "camera", of your 3d-scene is attached to one tripod and whatever object you are drawing is attached to another. Then the projection matrix controls the position and rotation of the tripod attached to the camera while the modelview matrix controls the tripod attached to the 3d object you're drawing.

glMatrixMode just sets which one of the matrices you are going to manipulate. Then using methods such as glRotate and glTranslate you move around the current tripod.

Changing the modelview matrix for each object you draw, you can set it up so that the different objects in your scene sits on different tripods and can be positioned and rotated individually. Using glPushMatrix and glPopMatrix you can even attach tripods to each other in complex chains.

Anyay, enough of the tripod analogy. I'd advice you to read up on the subject in the chapter on viewing (chapter 3?, at least in the older revisions) in the OpenGL red book as well as brush up on linear algebra and matrix math.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this