# Matrices Confusion (MODELVIEW / PROJECTION)

• 08-21-2009
Jake.c
Matrices Confusion (MODELVIEW / PROJECTION)
I can't seem to find a solid explanation of these anywhere. I understand that GL_PROJECTION is the default and does not need to be changed to draw a simple square. Yet I have heard that GL_MODELVIEW is for drawing, and GL_PROJECTION is for turning the 3d into a 2d projection.

I really don't understand it (if you need modelview to draw, how can a simple program draw a square on GL_PROJECTION opengl default?). Could anyone lend a minute to explain these from a beginners point of view and when each might be used.

Thanks =)
• 08-21-2009
VirtualAce
A projection matrix does the necessary divide by w which turns 3D into 2D and brings the system into clip space.

A local/model matrix contains all the necessary translation, rotation, skewing, scaling, etc. information. A model matrix represents the sum total of the data necessary to orient the object correctly in local space.

A world matrix contains all the necessary information to orient the object in world space.

A view matrix is used to push the world matrices into view space or camera space. This is how the world looks from the viewpoint of the camera.

The final transform is:

Model * World * View * Projection

Model * World = World space
Model * World * View = Camera/View space
Model * World * View * Projection = Clip space

However you will see a worldviewprojection matrix used in many books and API docs. The WVP matrix is: world * view * projection. Often it is more efficient to pass in the WVP to a shader as a pre-concatenated matrix which is why it is done this way.

As well remember that an inverse matrix will effectively undo the transform. So an inverse world matrix will undo a world transform and will bring the system back into local/model space.

Most of the time when people refer to a modelview the model matrix is actually the concatenation of the local and world matrices for that particular object which has been concatenated with the view matrix from the camera.