Basic questions about projection matrix

Hi all,
I’m using a Ladybug3 camera from Point Grey to get a panoramic image. To display the image I use the camera API. After I called the display function my projection matrix has changed. This is the array I get when I call glGet(GL_PROJECTION_MATRIX, matrix):
matrix = {1.0909, 0, 0, 0, 0, 2.414217, 0, 0, 0, 0, -1, -1, 0, 0, -0.02, 0}

So here are my questions:

  1. Which ordering does a matrix in openGL have? Is it column- or row-major ordering? So how would this matrix look like when you write it in a “normal” form?

  2. Is it possible to get the near and far value of the frustum out of this matrix. Or is there a function to get them?

Thank you :wink:

OpenGL uses column-major storage order with operator-on-the-left transform order (e.g. PVM * pos_obj = pos_clip).

This results in the same matrix element storage order in memory as row-major storage order with operator-on-the-right transform order (e.g. pos_obj * MVP = pos_clip).

Obviously the latter is more convenient in C/C++, and avoids a bunch of needless transposes when talking to OpenGL. So in other words, when working in C/C++, just flip your transforms left-to-right (i.e. use the operator-on-the-right transform order) and treat your matrices as row-major like you’d like.

Yeah, take a look at the form of the Perspective Projection matrix (which your apparently using) in the OpenGL Programming Guide (Appendix: Homogenous Transforms), or look here.

Multiply this by (0,0,z_eye, w_eye) to get (0,0,z_clip, w_clip). Now divide z_clip/w_clip to get z_ndc. So this gives you a function for z_ndc as a function of z_eye. At the near clip you know, z_ndc = -1. From the matrix, you also know all the other terms in the simple equation except for z_eye. Just solve for z_eye. It’s something like -1 = -m22 - m23 * (1/zeye). For far clip, z_ndc is 1 instead of -1.

Okay thanks. I think I have some problems with the basics of projection. So I opened another topic. Please take a look at this:…amp;#Post298924