Skip to main content
gamedev.net
🔒 Locked

Untitled

Started by giugio Aug 15, 2008 at 10:09 AM 1 replies 800+ views
Original Post
giugio
giugio
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
	gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);

	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix
	glLoadIdentity();			

thanks
Gorax
Gorax
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.
Luctus
Luctus
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.
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.