OGL Stereo Draw

Once you create a context with stereo draw (via the pixel format on context creation)…

  1. The GL_BACK_LEFT and GL_BACK_RIGHT are two completely different buffers correct?

  2. When you set glDrawBuffer(GL_BACK) and draw, does it renders the same image to both the left and right buffers at the same time?

  3. What happens when you set glReadBuffer(GL_BACK) and do a read operation? (glReadPixels, glCopyTexImage, etc)? Is either the left or right buffer just choosen?

  4. If you draw the left eye (into GL_BACK_LEFT), then draw the right eye (into GL_BACK_RIGHT)… do you need to swap immediately or can you draw into the back (GL_BACK) to add an overlay effect to both buffers before you swap?

Well you need a quadro card for a quad buffered pixel format.

  1. The GL_BACK_LEFT and GL_BACK_RIGHT are two completely different buffers correct?

Yes.

  1. What happens when you set glReadBuffer(GL_BACK) and do a read operation? (glReadPixels, glCopyTexImage, etc)? Is either the left or right buffer just choosen?

Back left.

  1. If you draw the left eye (into GL_BACK_LEFT), then draw the right eye (into GL_BACK_RIGHT)… do you need to swap immediately or can you draw into the back (GL_BACK) to add an overlay effect to both buffers before you swap?

you can draw whatever you want into the buffers, but they share a single depth buffer. So normally how it works is, you render the left image, clear the depth buffer then render into the right buffer.

Yep, I understand that. I want to know if drawing to the back buffer (using glDrawBuffers(GL_BACK)) after that (but before the swap) causes issues?

In other words, I know this works…

  1. Clear Color Buffer.
  2. Clear Depth Buffer.
  3. Draw Left Eye.
  4. Clear Depth Buffer.
  5. Draw Right Eye.
  6. Swap.

However, does the following work (or does it screw things up when you draw to the back buffer at the end)…

  1. Clear Color Buffer.
  2. Clear Depth Buffer.
  3. Draw Left Eye.
  4. Clear Depth Buffer.
  5. Draw Right Eye.
  6. Clear Depth Buffer.
  7. Draw Overlay into GL_BACK (which renders into both left and right?)
  8. Swap.

I ask because I have rendered two textures (one for the left eye, one for the right eye) and I am trying to get a stereo effect by…

  1. Clearing the depth/color buffers.
  2. Drawing texture one using a screen aligned quad into GL_BACK_LEFT.
  3. Drawing texture two using a screen aligned quad into GL_BACK_RIGHT.
  4. Drawing an overlay using immediate mode into GL_BACK.
  5. Calling swap.

But it does not seem to be working.

  1. Draw Overlay into GL_BACK (which renders into both left and right?)

No, it does not. When doing quad-buffer stereo, GL_BACK is just an alias for GL_BACK_LEFT.

Ah ok, was wondering about that. Thanks :wink:

Yeah that’s pretty much how it works. The quad buffer api is almost dead though.

You are better off just drawing to 2 opengl windows seperately.

Are you sure of this? man glDrawBuffer states:

GL_BACK: Only the back left and back right color buffers are written. If there is no back right color buffer, only the back left color buffer is written.

Which matches what I’ve observed on NVidia cards at least.

From what I am seeing, I think I have to agree. I draw into GL_BACK and can then do a read from GL_BACK_LEFT or GL_BACK_RIGHT and get the same image?

you need to set a quad buffered pixel format
and for that you probably need a quadro card