PDA

View Full Version : OGL Stereo Draw



PickleWorld
01-13-2011, 09:45 AM
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?

dukey
01-13-2011, 09:59 AM
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.


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?
Back left.


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?
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.

PickleWorld
01-13-2011, 12:47 PM
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.

PickleWorld
01-13-2011, 12:50 PM
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.

Alfonse Reinheart
01-13-2011, 01:05 PM
7) 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.

PickleWorld
01-13-2011, 01:13 PM
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 ;)

dukey
01-13-2011, 05:55 PM
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.

eile
01-14-2011, 02:17 AM
7) 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.

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.

PickleWorld
01-14-2011, 07:23 AM
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?

dukey
01-14-2011, 12:24 PM
you need to set a quad buffered pixel format
and for that you probably need a quadro card