We get from another application a Projection Matrix of dimension 3x4, which maps 3d points (homogeneous coordinates) to the image plane (2d points, homogeneous coordinates).
Now we want to use this matrix in opengl.
The problems we encounter are
There seems to be no direct access to the “final” projection matrix, which consists of modelview-matrix, projection-matrix, viewport in terms of opengl naming.
Our Matrix is of dimension 3x4 (which is mathematically correct if you project from 3d to 2d environment) - matrix dimensions in opengl (for modelview matrix, projection matrix) are 4x4!!
a) How does opengl achieve 3d to 2d projection (with 2d meaning the screen) using 4x4 matrices???
b) How can we use our matrix in opengl under these circumstances?
Thanks for any hints!
Matrix transforms are explained at the back of the red book, Apendix f in the OpenGL 1.2 version of the book.
The transformation in OpenGL is accomplished by multiplying the vector by the matrix. Then of course you have the homogeneous divide.
There’s more to this than simply emulating OpenGL since there is a predetermined coordinate frame in OpenGL with y pointing up and z out of the screen, to get transformed to eyespace with appropriate z as produced by a glfrustum call.
I expect adding a row should give you what you want, but there’s the reversed row column order in OpenGL w.r.t. classic matrix notation so you may want to check your in memory 4x4 representation against the row column order expected by OpenGL since that may throw you off.
We know the part of the red book you mentioned, also we think that we understand what you mean (except for the part with glfrustum…?) - however, I think our problem is more complex, more theoretical: If you have a projection from 3d to 2d you mathematically need a 3 x 4 Matrix (homogeneous ccordinates). because you go from xyz space to xy space.
If we just add another row, i.e. set z=const (e.g. z=0) in 2d space, is that mathematically correct? I am not so sure… So we wonder how opengl achieves this and how we can interface our 3x4 matrix to opengl…
we apprechiate any help, if we can’t solve this, maybe opengl is not the right tool, which would be a pitty…
OpenGL doesn’t go to 2d coords just there. Z is carried through for Z buffering, so it’s still a 3d coordinate in the end (plus w).
If you don’t need Z, just discard it.