PDA

View Full Version : setting/updating the PROJECTION matrix using glLoadMatrix()



Scott_I
11-14-2005, 12:17 PM
I'm working on an exercise where I'm keeping total track of the PROJECTION and MODELVIEW matrix stacks myself using my own data structures, and updating the actual PROJECTION/MODELVIEW matrix only when needed using glLoadMatrix()

I've done the necessary functions for modifying the MODELVIEW matrix (my own glrotate, gltranslate, glscale, glPop, glPush "type" functions), and its working as expected.

I'm not sure about projection matrix... What happens to the PROJECTION matrix when the following is done:
glMatrixMode(PROJECTION);
glLoadIdentity(); //obvious here..
glOrtho3d(); //but what about after this?

Could anyone give me some hints as to how to set up the PROJECTION matrix. Or maybe a link to where I could learn more about it?

Thanks.

dorbie
11-14-2005, 03:40 PM
This is documented in the specification

http://www.opengl.org/documentation/spec...000000000000000 (http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node25.html#SECTION005102000000000000000)

and in the man page for glOrtho

http://www.hmug.org/man/3/glOrtho.php


2
------------ 0 0 tx
right - left

2
0 ------------ 0 ty
top - bottom


-2
0 0 ------------ tz
zFar-zNear

0 0 0 1


where

tx = - (right + left) / (right - left)

ty = - (top + bottom) / (top - bottom)

tz = - (zFar + zNear) / (zFar - zNear)

Scott_I
11-14-2005, 04:12 PM
Thanks alot. This is very helpful.