Stereoscopic display

In the past I was using Open Scene Graph when I wanted to display something in stereo, so I don’t know how to do it just with OpenGL.

I’ve done some research and here are a few useful links :

- This guy did a lot of work about stereographics, and he also put some OpenGL code :

http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/stereographics/stereorender/

http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/stereographics/ 

- I need to use Active Stereo, and the only way I know to do that is to use the Quadro FX driver from nVidia : http://www.nvidia.com/object/quadro_stereo_technology.html

Here is what I’ve found on the forum nvidia :

“This is correct. Stereo support is one of the selling points of the Quadros. The specific feature is called quad buffers. That is; left and right front and back buffers.
To use quad buffers, first select a pixel format with quad buffers/stereo support.
Then use glDrawBuffer(GL_BACK_LEFT/GL_BACK_RIGHT) to select the buffer. No openGL extensions or special API needed.”

http://developer.nvidia.com/forums/index.php?showtopic=3007

So, apparently I just need to set the “stereo” flag in my pixel format when the OpenGL context is created (which means using WX_GL_STEREO : http://docs.wxwidgets.org/2.8/wx_wxglcanvas.html)

and then I need to render twice the scene using glDrawBuffer(GL_BACK_LEFT) and glDrawBuffer(GL_BACK_RIGHT) , like this :

http://www.orthostereo.com/geometryopengl.html  

GLvoid display(GLvoid)
{
  glDrawBuffer(GL_BACK);                                   //draw into both back buffers
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);      //clear color and depth buffers

  glDrawBuffer(GL_BACK_LEFT);                              //draw into back left buffer
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();                                        //reset projection matrix
  glFrustum(leftCam.leftfrustum, leftCam.rightfrustum,     //set left view frustum
            leftCam.bottomfrustum, leftCam.topfrustum,
            nearZ, farZ);
  glTranslatef(leftCam.modeltranslation, 0.0, 0.0);        //translate to cancel parallax
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity);
  glPushMatrix();
  {
    glTranslatef(0.0, 0.0, depthZ);                        //translate to screenplane
    drawscene();
  }
  glPopMatrix();

  glDrawBuffer(GL_BACK_RIGHT);                             //draw into back right buffer
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();                                        //reset projection matrix
  glFrustum(rightCam.leftfrustum, rightCam.rightfrustum,   //set left view frustum
            rightCam.bottomfrustum, rightCam.topfrustum,
            nearZ, farZ);
  glTranslatef(rightCam.modeltranslation, 0.0, 0.0);       //translate to cancel parallax
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity);

  glPushMatrix();
  {
    glTranslatef(0.0, 0.0, depthZ);                        //translate to screenplane
    drawscene();
  }
  glPopMatrix();
  
  glutSwapBuffers();
}

I don’t remember what kind of grpahics card we have in the lab, so I’m not sure I’ll be able to test it here. I need to check that.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.