PDA

View Full Version : stereo viewing



Ehsan Kamrani
06-02-2005, 08:33 AM
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-

carl_lewis
06-02-2005, 08:49 AM
what's the value of EYE_BACK?



sounds like you're not actually far enough away from the geometry to focus properly

Ehsan Kamrani
06-02-2005, 09:24 AM
I'm a bit confused. When i disable these lines:

glDrawBuffer( GL_BACK_LEFT );
glDrawBuffer( GL_BACK_RIGHT );

The resulting scene doesn't change!
(I have declared the PFD_STEREO flag in my PIXELFORMATDESCRIPTOR structure )

In my program:
IOD = 0.5
EYE_BACK = 10

And i have used from the following view volume:
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);

-Ehsan-

dorbie
06-02-2005, 08:13 PM
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.

Ehsan Kamrani
06-03-2005, 03:11 AM
Thanks.I'll try to do your instructions :)
-Ehsan-

Ehsan Kamrani
06-03-2005, 07:53 AM
I understand that SetPixelFormat() cannot set the PFD_STEREO. When i use from the following code, i see the error message:

if( PixelFormat = GetPixelFormat( hDC ) )
{
DescribePixelFormat( hDC, PixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd );
if( (pfd.dwFlags & PFD_STEREO) == 0 )
{
KillGLWindow();
MessageBox(NULL,"Stereo viewing failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE;
}

But why?My graphics card is GeForce4 MX 4000. It should support it.Should i change some settings of my graphics card?
-Ehsan-

ZbuffeR
06-03-2005, 08:23 AM
I though real stereo support was only enabled in the Quadro professional cards.

Relic
06-03-2005, 08:25 AM
>>But why?My graphics card is GeForce4 MX 4000. It should support it.Should i change some settings of my graphics card?<<

No, GeForce boards don't support stereo pixelformats.

Ehsan Kamrani
06-03-2005, 08:31 AM
Awww.That's too bad. :( Thanks for your replies.
-Ehsan-