Results 1 to 6 of 6

Thread: Why Save The Matrix?

  1. #1
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Why Save The Matrix?

    No, I'm not talking about some hippy program to save all those machines that conqoured the human race and enslaved us all in the distant fictional future.

    I'm just wondering for the sake of edification why is it that we would want to save this matrix when working with OpenGL to draw a new primitive?

    What valuable information is stored here and what why would it get lost if we didn't save it?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #2

    Re: Why Save The Matix?

    Quote Originally Posted by WILL
    I'm just wondering for the sake of edification why is it that we would want to save this matrix when working with OpenGL to draw a new primitive?

    What valuable information is stored here and what why would it get lost if we didn't save it?
    if you change it (gltranslated / glrotatef / glscalef) then you should restore it with glpushmatrix / glpopmatrix mechanism, otherwise everything after you change it will follow the modified matrix...
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  3. #3
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Why Save The Matrix?

    Ah.. so it's just like a rendering brush of sorts then?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  4. #4

    Why Save The Matrix?

    Quote Originally Posted by WILL
    Ah.. so it's just like a rendering brush of sorts then?
    eh?

    when you come into your rendering loop you make the matrix using glulookat or similar functions, when you change the matrix, you have to save previous state, otherwise all geometry you draw after change will follow the changed matrix, so you'd have to use routines to recreate your original matrix all the time which would be much more time consuming process.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  5. #5

    Why Save The Matrix?

    Think about it in 2D to understand the principle like I told you.

    Think of a plotter which draws a line at some point. Not resetting after drawing will draw the next point from the end of the line. Resetting will draw the next line fom origin again. Both has advantages, and you need both possibilities. For example, you draw a cube in 3D. You know dimensions, rotation and scale of that cube, draw the first face and go on from that point.

    Drawing a second cude on another place, you would like to reset the matrix before, because you still have the position, rotation and scale of the first cube stored in the matrix.

    Got it?
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  6. #6
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Why Save The Matrix?

    Ok I've got it now. Thanks guys.

    Just something that was floating around in my head the other day while messing with some stuff.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •