Thread: Matrices Confusion (MODELVIEW / PROJECTION)

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    47

    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 =)

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C simple Matrices
    By Cyberman86 in forum C Programming
    Replies: 3
    Last Post: 05-07-2009, 05:20 PM
  2. Help getting started..matrices
    By BobDole11 in forum C Programming
    Replies: 7
    Last Post: 11-15-2008, 09:51 PM
  3. adding matrices, help with switches
    By quiet_forever in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2007, 08:21 AM
  4. Comparing Matrices (D3D9)
    By MicroFiend in forum Game Programming
    Replies: 2
    Last Post: 10-12-2005, 08:36 AM
  5. Problem multiplying rotation matrices together
    By Silvercord in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 03-04-2003, 09:20 AM