glOrtho question

Okay, here’s a simple question. What really goes on in glOrtho ()? I’m looking at this url: http://www.opengl.org/developers/documen…ortho#first_hit

However, when it attempts to describe how the matrix is setup, the numerators are all missing… which doesn’t help.

Well, I found my answer here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc03_8qnj.asp

However, I’m still a bit confused. Since I can’t find out how to read matrix from the opengl stack (is it possible?) I managed to initialize a vertex shader and setup its trackview to store the projection into register c[0]-c[3] and inspected; I found that the matrix produced by glOrtho () was diffrent than the one that I setup. I’m not sure what I’m doing wrong… here’s some sample code:

void mSetOrthographic (int left, int top, int right, int bottom, float n, float f)
{
float fTerm1 = 2.0f / (right - left);
float fTerm2 = 2.0f / (bottom - top);
float fTerm3 = 2.0f / (f - n);
float fTerm4 = (float) -(right + left) / (float) (right - left);
float fTerm5 = (float) -(bottom + top) / (float) (bottom - top);
float fTerm6 = (float) -(f + n) / (float) (f - n);

tMtx4x4	&m = fProjectionMtx.mGetMtx4x4();
m[0][0] = fTerm1;	m[1][0] = 0.0f;		m[2][0] = 0.0f;		m[3][0] = fTerm4;
m[0][1] = 0.0f;		m[1][1] = fTerm2;	m[2][1] = 0.0f;		m[3][1] = fTerm5;
m[0][2] = 0.0f;		m[1][2] = 0.0f;		m[2][2] = fTerm3;	m[3][2] = fTerm6;
m[0][3] = 0.0f;		m[1][3] = 0.0f;		m[2][3] = 0.0f;		m[3][3] = 1.0f;

fProjectionMtx.mSet3x4Flag( kFalse );

Any idea what I’m doing wrong?

Microsoft’s opengl documentation is not that inspiring - you should really get the redbook, pref. paper editon so you can study even without a computer (ie in bed, when walking, etc). You can get an older version online: http://www.opengl.org/developers/documentation/specs.html

I have the redbook, but it doesn’t explicitly say what the output of glOrtho () is.

I think that to get matrix from OpenGL stack simply use
glGetFloatv(GL_MODELVIEW (or GL_PROJECTION) , matrix]); where matrix is a float[16]

The redbook gives all the formulas used for glOrtho, glFrustum, glRotate, glTranslate, glScale, etc. in an appendix at the back of the book.

Also, I believe all the formulas used for anything OpenGL related can be found in the OpenGL specification. You can find a link to that somewhere from the main site here, under Documentation.

[This message has been edited by Deiussum (edited 12-12-2002).]