stereographic display and glfrustum
Posted: 27.01.2006, 02:10
I am trying to modify celestia to allow proper stereographic viewing (we are a University astronomy group http://vr.swin.edu.au). The first thing I need to do is convert all calls to gluperspective to glfrustum. This is needed to have non symetric frustums for the left and right eyes. However this seems to be harder than I expect.
As a simple test I have changed the first call to gluperspective in renderer::render() in render.cpp to a glfrustum as follows
//work out the scaling between the screen and the near camera clip, as we compute frustum positon from screen size
GLdouble resRatio = (float) windowWidth / (float) windowHeight;
GLdouble rfov = degToRad(fov/2.0);//radians
GLdouble screenH = NEAR_DIST*tan(rfov);
GLdouble t = screenH; //top
GLdouble b = -t; //bottom is -top
GLdouble l = t * resRatio; //left is the ratio of width/height*top
GLdouble r = -l; //right is -left
// Set up the projection we'll use for rendering stars.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(stereo)
{
glFrustum(l,r,b,t,NEAR_DIST,FAR_DIST);
}
else
{
gluPerspective(fov,
(float) windowWidth / (float) windowHeight,
NEAR_DIST, FAR_DIST);
}
this is all that is changed. My understanding is that these two calls are essentially the same.
However whenever when I call glfrustum instead of gluperspective the stars are no longer drawn as disks or fuzzy points. Only points will work. If I change all of the gluperspective calls things get worse, such as planet faces being rendered inverted.
Is there any inherent reason why celestia needs to use gluperspective? Is it a gl bug? I am us osx 10.4.4.
Thanks in advance
As a simple test I have changed the first call to gluperspective in renderer::render() in render.cpp to a glfrustum as follows
//work out the scaling between the screen and the near camera clip, as we compute frustum positon from screen size
GLdouble resRatio = (float) windowWidth / (float) windowHeight;
GLdouble rfov = degToRad(fov/2.0);//radians
GLdouble screenH = NEAR_DIST*tan(rfov);
GLdouble t = screenH; //top
GLdouble b = -t; //bottom is -top
GLdouble l = t * resRatio; //left is the ratio of width/height*top
GLdouble r = -l; //right is -left
// Set up the projection we'll use for rendering stars.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(stereo)
{
glFrustum(l,r,b,t,NEAR_DIST,FAR_DIST);
}
else
{
gluPerspective(fov,
(float) windowWidth / (float) windowHeight,
NEAR_DIST, FAR_DIST);
}
this is all that is changed. My understanding is that these two calls are essentially the same.
However whenever when I call glfrustum instead of gluperspective the stars are no longer drawn as disks or fuzzy points. Only points will work. If I change all of the gluperspective calls things get worse, such as planet faces being rendered inverted.
Is there any inherent reason why celestia needs to use gluperspective? Is it a gl bug? I am us osx 10.4.4.
Thanks in advance