[visionegg] Re: Stereo and PyOpenGL
- From: "Kevin J. MacKenzie" <kjmacken@xxxxxxxx>
- To: visionegg@xxxxxxxxxxxxx
- Date: Thu, 14 Oct 2004 13:57:32 -0400
Hi there Andrew,
Andrew Straw wrote:
Thanks for your work on this. I think stereo capabilities nicely
enhance the Vision Egg.
More thanks should also go to Yuichi Sakano who has done a lot of the
work here.
I've gone ahead and modified Core.py along similar lines to what your
files did. In addition, I've integrated a stereo option with the GUI
startup window and the VisionEgg.cfg preferences file. You can get
the changes from CVS. (Email me if you want a source tarball or zip.)
Sounds perfect. I'll take a look at CVS, maybe e-mail for a last minute
"save me" call.
Unfortunately, none of the computers/video cards I have seems to
support stereo, so I wasn't able to test my work or to help with your
problem below. I noticed in your provided demo that you are calling
glDrawBuffer() to set whether you're drawing to the left or right
framebuffer, which seems to be the right thing to do. If we can
resolve the problems you list, I'd love to include this demo with the
Vision Egg, giving you appropriate credit, of course.
What system are you doing stereo on? If I do have access to the right
equipment, I'd be interested to try it out.
I have been using OS 10.3 on 2 different Apple G4's, as well as a G4
iBook with an ATI 9200 mobility. For stereo I use the StereoGraphics
(TM) crystal eyes hardware, and blue line syncing. One machine is using
an ATI radeon 9200, the one one an ATI All in Wonder series (older card).
However, I have noticed a visual artifact that exists after modifying
the Core.Screen.__init__() function. I have attached the modified
Core.py and some sample code written by Yuichi which uses the Dots2D
stimulus class and presents a fixation square in stereo depth.
I'm not sure what you mean by "visual artifact". Can you elaborate
further?
I think I was wrong with calling it a visual "artifact". What is
happening is that only one of the back buffers is being drawn to with
normal 2D stimuli (try running some of the VisionEgg demos with the
Core.py file I submitted, it may illustrate what I mentioned).
With only one back-buffer being written to (when not "wanting stereo"),
I am getting a display that will flicker between my desktop, and the
stimulus I am drawing to the screen. I haven't had the chance to get
back to this in the past week, but Yuichi and I am optimistic a work
around will be found.
After running this code, and then looking at another VisionEgg demo,
I notice that one of the frame buffers still has one of the left- (or
right) images from the stereo presentation.
Perhaps this is the visual artifact you refer to above? Regardless,
this is strange. Is this after the first script has ended and you've
started Python again?
Exactly what I was refering to. This specific issue is immediately
after running the script using:
$ pythonw <scriptWithStereo>.py # needs pythonw here for access to the
window manager for OS X.....
Also, the addition of:
pygame.display.gl_set_attribute(pygame.locals.GL_STEREO,1)
to Core.Screen.__init__() causes all of the demos to run at 1/2 the
expected frame rate (ie. 30 fps on a 60 HZ LCD, 60 fps on a 120 HZ
CRT monitor). I am thinking that this is due to splitting the
available viewport into 2 frame buffers (for left- and right-eye
presentation).
Perhaps...
Is there a way to pass an argument to Core.Screen.__init__(), which
would initialize stereo presentation when required, and to not elicit
this behaviour when it is not?
Done in the set of changes I just checked in. (I made the main
changes at the end of last week but the specific ability to use
is_stereo as a parameter to Screen.__init__() was only done this
morning, so it may not show up on the public CVS server for a couple
days.)
I will have to take a look at this and try a few things out. Sounds
like this implemented change is exactly the workaround required.
I tried simply renaming the modified Core.py file "StereoCore.py", to
import when Stereo is required. However, this seems to have broken
some of the Core.Stimulus classes, and they no longer seem to function.
I figure that I could simply treat each stimulus as a stereo image,
and send a left-right presentation through the viewport, however,
this seems to be more code than what would be ideal per stimulus
presentation.
I think the changes I checked in should address these issues. Let me
know if they work or if you need me to send you a copy of the files.
Also, I'm not to clear on how Python handles the video buffering, and
don't know how to clear the frame buffers after they are used and are
no longer required. If I could clear the vram after a stereo
presentation, it would at least get rid of the artifact.
I did see on an OpenGL article about stereo (
http://astronomy.swin.edu.au/~pbourke/opengl/stereogl/ ) that you can
call glDrawBuffer(GL_BACK) before calling glClear(...). Since the
Vision Egg does the glClear() work, I suggest calling
glDrawBuffer(GL_BACK) when you're done drawing the individual buffers.
Will give that a shot.
Please let us know how you go on this!
Of course. It may be a few days before I can get to it
(grant/scholarship deadlines looming eek!), but I will plug away on it ASAP.
I'll try to get the CVS version before harrasing you for copies of the
files :).
Thanks a lot Andrew!
Kevin
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html
- References:
- [visionegg] Re: Stereo and PyOpenGL
- From: Kevin J. MacKenzie
- [visionegg] Re: Stereo and PyOpenGL
- From: Andrew Straw
Other related posts:
- » [visionegg] Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
- » [visionegg] Re: Stereo and PyOpenGL
Thanks for your work on this. I think stereo capabilities nicely enhance the Vision Egg.
I've gone ahead and modified Core.py along similar lines to what your files did. In addition, I've integrated a stereo option with the GUI startup window and the VisionEgg.cfg preferences file. You can get the changes from CVS. (Email me if you want a source tarball or zip.)
What system are you doing stereo on? If I do have access to the right equipment, I'd be interested to try it out.
I'm not sure what you mean by "visual artifact". Can you elaborate further?
After running this code, and then looking at another VisionEgg demo, I notice that one of the frame buffers still has one of the left- (or right) images from the stereo presentation.
Perhaps this is the visual artifact you refer to above? Regardless, this is strange. Is this after the first script has ended and you've started Python again?
Also, the addition of:
pygame.display.gl_set_attribute(pygame.locals.GL_STEREO,1)
to Core.Screen.__init__() causes all of the demos to run at 1/2 the expected frame rate (ie. 30 fps on a 60 HZ LCD, 60 fps on a 120 HZ CRT monitor). I am thinking that this is due to splitting the available viewport into 2 frame buffers (for left- and right-eye presentation).
Perhaps...
Is there a way to pass an argument to Core.Screen.__init__(), which would initialize stereo presentation when required, and to not elicit this behaviour when it is not?
Done in the set of changes I just checked in. (I made the main changes at the end of last week but the specific ability to use is_stereo as a parameter to Screen.__init__() was only done this morning, so it may not show up on the public CVS server for a couple days.)
I tried simply renaming the modified Core.py file "StereoCore.py", to import when Stereo is required. However, this seems to have broken some of the Core.Stimulus classes, and they no longer seem to function.
I figure that I could simply treat each stimulus as a stereo image, and send a left-right presentation through the viewport, however, this seems to be more code than what would be ideal per stimulus presentation.
I think the changes I checked in should address these issues. Let me know if they work or if you need me to send you a copy of the files.
Also, I'm not to clear on how Python handles the video buffering, and don't know how to clear the frame buffers after they are used and are no longer required. If I could clear the vram after a stereo presentation, it would at least get rid of the artifact.
I did see on an OpenGL article about stereo ( http://astronomy.swin.edu.au/~pbourke/opengl/stereogl/ ) that you can call glDrawBuffer(GL_BACK) before calling glClear(...). Since the Vision Egg does the glClear() work, I suggest calling glDrawBuffer(GL_BACK) when you're done drawing the individual buffers.
Will give that a shot.
Please let us know how you go on this!
- [visionegg] Re: Stereo and PyOpenGL
- From: Kevin J. MacKenzie
- [visionegg] Re: Stereo and PyOpenGL
- From: Andrew Straw