• Create Account

### #ActualSuperVGA

Posted 21 July 2013 - 07:27 AM

Perhaps I don't understand your problem. If you have (the equivalent of) the following setup:

glMatrixMode(GL_PROJECTION);
glFrustum(..., 0.1, 32);

glMatrixMode(GL_MODELVIEW);
glLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, up.x, up.y, up.z);


then the equivalent orthographic view is:

glMatrixMode(GL_PROJECTION);
glOrtho(l, r, t, b, 0.1, 32);

glMatrixMode(GL_MODELVIEW);
glLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, up.x, up.y, up.z);


where you have to adjust l, r, t and b to get the desired horizontal and vertical scaling. The orthographic view will be from the same location, towards the same target location and with the same depth range. Is this what you're trying to achieve?

Yes, it's exaclty that. Only, I cannot make it do that. I have a viewport 0,0 -> 800, 600 and set l=-1.0, r=1.0, t=1.0, b=1.0, -1.0

from a view looking from 0.5, -0.5, 0.5 towards 0.5, 0.5, 0.5 where up.z = {0, 0, 1}

I have a 90 deg perspective projection that i can swap with, near set to 0.1 and far to 2.0, still, i draw an object at 0,0,0 (with lengths of all bound sides == 1.0)

Still i end up getting a view as if the depth test was reversed (as if the ortho eye is being far away, looking back at where it should've been),

where the perspective projection shows what is expected off the given parameters.

### #1SuperVGA

Posted 21 July 2013 - 07:26 AM

Perhaps I don't understand your problem. If you have (the equivalent of) the following setup:

glMatrixMode(GL_PROJECTION);
glFrustum(..., 0.1, 32);

glMatrixMode(GL_MODELVIEW);
glLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, up.x, up.y, up.z);


then the equivalent orthographic view is:

glMatrixMode(GL_PROJECTION);
glOrtho(l, r, t, b, 0.1, 32);

glMatrixMode(GL_MODELVIEW);
glLookAt(eye.x, eye.y, eye.z, target.x, target.y, target.z, up.x, up.y, up.z);


where you have to adjust l, r, t and b to get the desired horizontal and vertical scaling. The orthographic view will be from the same location, towards the same target location and with the same depth range. Is this what you're trying to achieve?

Yes, it's exaclty that. Only, I cannot make it do that. I have a viewport 0,0 -> 800, 600 and set l=-1.0, r=1.0, t=1.0, b=1.0, -1.0

from a view looking from 0.5, -0.5, 0.5 towards 0.5, 0.5, 0.5 where up.z = {0, 0, 1}

I have a 90 deg perspective projection that i can swap with, near set to 0.1 and far to 2.0, still, i draw a cube it 0,0,0 (with lengths of all sides == 1.0)

Still i end up getting a view as if the depth test was reversed (as if the ortho eye is being far away, looking back at where it should've been),

where the perspective projection shows what is expected off the given parameters.

PARTNERS