View Full Version : glOrtho question
12-11-2002, 04:24 PM
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 (http://www.opengl.org/developers/documentation/man_pages/hardcopy/GL/html/gl/ortho.html?glortho#first_hit)
However, when it attempts to describe how the matrix is setup, the numerators are all missing... which doesn't help.
12-11-2002, 04:46 PM
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-c 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 = fTerm1; m = 0.0f; m = 0.0f; m = fTerm4;
m = 0.0f; m = fTerm2; m = 0.0f; m = fTerm5;
m = 0.0f; m = 0.0f; m = fTerm3; m = fTerm6;
m = 0.0f; m = 0.0f; m = 0.0f; m = 1.0f;
fProjectionMtx.mSet3x4Flag( kFalse );
Any idea what I'm doing wrong?
12-11-2002, 06:06 PM
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
12-11-2002, 06:34 PM
I have the redbook, but it doesn't explicitly say what the output of glOrtho () is.
12-12-2002, 01:54 AM
I think that to get matrix from OpenGL stack simply use
glGetFloatv(GL_MODELVIEW (or GL_PROJECTION) , matrix]); where matrix is a float
12-12-2002, 05:27 AM
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).]
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.