Hi,
I am having difficulty understanding exactly how perspective projection works in OpenGL. I have created a frustrum with the following parameters:
l = -5, r = 5, t = 4, b = -4, n = 5, f = 15
Using the OpenGL blue book, I determined this should give the Matrix:
1 0 0 0
0 1.25 0 0
0 0 -2 -15
0 0 -1 0
The vertex I am trying to project is (0.0,0.0,-10.0), and when I multiply ths vertex by the projection matrix the result is (0.0,0.0,5.0)
As I understood it, the result of multipliying a vertex inside the frustum by the projection matrix would be a vertex within the unit cube, which the above result is not.
However, what I have found is that if after the multiplication I devide each element of the resulting vertex but it's w co-ordinate (which comes out as 10 in the above example), then the result is in the unit cube.
Why do I need to do this final division, and why can it not be built into the matrix multiplicatrion? Or am I missing something?
Thanks in advance,
David