# OpenGL Matrix Values

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

## 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 on other sites
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  121 5 9  132 6 10 143 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 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 on other sites
Wavarian:

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 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 on other sites
You can manage yourself every matrix used by OpenGL. It's not so difficult.

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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634134
• Total Posts
3015742
×