Jump to content
  • Advertisement
Sign in to follow this  
Wavarian

OpenGL Matrix Values

This topic is 4841 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I was just wondering if anyone knew of any online references that discussed what the values stored in each of OpenGL's matricies actually represent? I'm having some difficulty locating anything remotely relevant using google. Really I just want to know, as an example, what changes are made to the projection matrix when, say, gluPerspective() is called, and what changes are made to the modelview matrix when gluLookAt() is called. I'd like to understand the lower-level details of 3d graphics programming using OpenGL. Thanks a heap!

Share this post


Link to post
Share on other sites
Advertisement
Quote:
I was just wondering if anyone knew of any online references that discussed what the values stored in each of OpenGL's matricies actually represent? I'm having some difficulty locating anything remotely relevant using google.

Really I just want to know, as an example, what changes are made to the projection matrix when, say, gluPerspective() is called, and what changes are made to the modelview matrix when gluLookAt() is called.

I'd like to understand the lower-level details of 3d graphics programming using OpenGL.
I'm surprised google didn't turn up some stuff for you. I'd also recommend the Red Book - it has some appendices which discuss how some of the matrices are constructed.

Just to get you started, the first thing to understand is how OpenGL matrices are laid out in memory:
0 4 8  12
1 5 9 13
2 6 10 14
3 7 11 15
Probably the next most important thing is that OpenGL uses column vectors, so matrix-vector multiplication looks like this:

[11 12 13 14][x]
[21 22 23 24][y]
[31 32 33 34][z]
[41 42 43 44][w]

This affects how most matrices are constructed. For example, basis and translation vectors go in the columns of the matrix rather than the rows.

The modelview matrix represents an affine transformation - a linear transform followed by a translation. The linear transform goes in the upper-left 3x3 submatrix, the translation goes in the rightmost column, and the bottom row is [0 0 0 1].

Quite often the only linear transform that is applied is a rotation, in which case the 3x3 submatrix contains the orthonormal basis vectors of the local coordinate frame. In that case the matrix looks like this:
[xx yx zx tx]
[xy yy zy ty]
[xz yz zz tz]
[0 0 0 1 ]
gluLookAt() creates a matrix like the above, but inverted (inversion is a whole other topic). Really there's quite a bit to it, and I've only skimmed the surface here. But maybe it'll get you pointed in the right direction.

Share this post


Link to post
Share on other sites
Thanks, I'll just have to keep looking. I've had a look through the red book, but it doesn't discuss the low-level details, just that "oh hey here is glRotate, it can do all sorts of nice stuff like this".

Perhaps I should be searching for the principals of 3d rendering in general.

Rating++

Share this post


Link to post
Share on other sites
Wavarian:

http://www.gamedev.net/reference/articles/download/course1.pdf // always start here

http://www.stanford.edu/~wfsharpe/mia/mat/mia_mat2.htm // some real-world descriptions
http://www.mrc-cbu.cam.ac.uk/Imaging/Common/matrices.pdf // more math

:stylin:

P.S. Trying to find a tutorial I read a about a year ago - really in-depth with pictures, animated GIFs ... I'll post if I run across it.

Share this post


Link to post
Share on other sites
I just found this and it looks like it might be what I'm looking for.

I'll take a look at those links you posted as well, as soon as I get over this headache ^_^

Thanks alot, more ratings++

Share this post


Link to post
Share on other sites
You can manage yourself every matrix used by OpenGL. It's not so difficult.

Usefull links


  • Matrix faq (there are several versions recent and less recent but they are similar )


  • OpenGL spec here you can read how OpenGL works


  • Mesa 3D if you download the source you can read the code yourself (note that there is also the implementation of the original glut lib)(very short but very usefull)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!