I have enabled the stereo viewing in my PIXELFORMATDESCRIPTOR structue. I have used from the instructions suggested by Advanced graphics programming with OpenGL:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); /* the default matrix */
glPushMatrix()
glDrawBuffer(GL_BACK_LEFT)
gluLookAt(-IOD/2.0, 0.0, EYE_BACK,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
<viewing transforms>
<modeling transforms>
draw()
glPopMatrix();
glPushMatrix()
glDrawBuffer(GL_BACK_RIGHT)
gluLookAt(IOD/2.0, 0.0, EYE_BACK,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
<viewing transforms>
<modeling transforms>
draw()
glPopMatrix()
I believe that nothing is wrong in my code. But the result is too bad.Actually i see two independet objects and it’s not like a thing that our eyes see.When i decrease the value of IOD-As an example to 0.5-Then i see the problem that is occured in decaling a picture on another picture.The resulting scene in this case is like a scene that a cross eyed person sees!
-Ehsan-
Your inter pupil translation needs to happen in eye space. That means it will vary in orientation with heading. Just positioning the eye with a translate on x in the lookat call will not support the view being rotated.
In addition to this you need to set up an asymmetric projection that corresponds to the viewer’s relationship to the display.
So before you do your lookat apply the inter pupil distance as a translate to the modelview on the X axis, the glLookat should be exactly the same for both eyes.
Next consider the difference this translate makes to an eye in front of the display, and make the ajustments to the glFrustum left and right parameters when you set the projection.
Do this and will work perfectly if you get the numbers right.
FYI most people totally screw this up, this is the correct way to do stereo on most displays, deviation from this is almost always wrong.