Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Stereoscopic 3D in QGraphicsView
eyeballz80 last edited by
I'm an Optometrist who has written an PyQt4 application for vision therapy (for people with lazy eye, double vision, etc.) One thing this program does is show one image that is only visible to the left eye and another image that is only visible to the right eye. I got this to work pretty well using red/blue glasses and simply changing the color of QGraphicsItems to suit. I would really love to be able to use the capabilities of 3D TV's and monitors that use active shutter glasses to render a different image for each eye, which would involve making use of OpenGL. I have done extensive googling on this and came up with very little.
I have read that you can make OpenGL calls on a QGraphicsItem, but haven't been successful in doing so. Here's what I have so far: I have a QGraphicsView with a QGLWidget set as its viewport. I have two sub-classed QGraphicsItemGroups, one for the right eye and one for the left eye. OpenGL calls are made in the paint event of the QGraphicsItemGroup. I've read that it is possible to do this, but there weren't any examples and haven't had any luck making it work.
Does it even seem like I am on the right track with this? Is there anything in QT5 that would make this simpler? Any ideas would be greatly appreciated.
OpenGL has support for 3D via draw buffers.
With the usual double buffering setup when swap is called the GL_FRONT and GL_BACK buffers are swapped and you always draw to GL_BACK.
For 3D OpenGL has separate buffers for left and right eye: GL_FRONT_LEFT, GL_FRONT_RIGHT, GL_BACK_LEFT and GL_BACK_RIGHT.
So this would be something like:
glDrawBuffer(GL_BACK_LEFT); //draw the scene for left eye glDrawBuffer(GL_BACK_RIGHT); //draw the scene for right eye
The thing with a 3D and OpenGL though is that for whatever reason industry decided that it's not your average consumer thing. To output 3D signal to your TV the graphics driver needs to allow it. Most consumer drivers don't support stereoscopic OpenGL. You need a "professional" card like NVidia Quadro or ATI FirePro 3D. It's actually the same hardware as the usual geforce or radeon except the drivers are different and for that you pay extra :(
That's why you don't see any OpenGL games work with things like NVidia 3D Vision and it's a shame really but that's how it is.