I want my application to correctly detect the presence of a quad buffered video card, so I can enable stereo viewing, only when 3D viewing is possible.
I have two Mac computers here: 1) Mac Pro Mac OS 10.6.8 desktop with nvidia Quadro 4000 video card ; 2) MacBook Pro laptop Mac OS 10.6.8 with two video boards a: built in Intel HD graphics and b: nvidia GeForce 330M.
The first computer has a connector for 3D glasses on the card. That's the one I want to display stereo 3D on. I don't think it's possible to view hardware stereo on the second laptop computer. So I want my application to detect which sort of computer it is on, and react appropriately. I thought I knew how to do that. But it isn't working. My application thinks quad buffered stereo works on both computers.
Witness a simple test program:
#!/usr/bin/python
"""
Test program to demonstrate apparent quad-
buffered stereo support on Mac laptop
"""
from OpenGL.GL import *
from PySide.QtGui import QMainWindow, QApplication
from PySide.QtOpenGL import QGLWidget, QGLFormat
import sys
class MyGLWidget(QGLWidget):
"Simple OpenGL canvas to test stereoscopic display capabilities"
def __init__(self, parent=None):
# Constructor for QGLWidget grabs a default OpenGL context
# (which was set up in the main program, below)
QGLWidget.__init__(self, parent)
if self.format().stereo():
# According to Qt docs, this is supposed to be the way to detect
# quad buffered stereo support
print "Quad buffered stereo appears to work(2)"
self.useStereo = self.format().stereo()
def initializeGL(self):
"initializeGL is called once, after the OpenGL context is really ready"
print "initializeGL"
if glGetBooleanv(GL_STEREO):
# This is the real OpenGL way to detect quad buffered stereo
print "Quad buffered stereo appears to work(3)"
self.useStereo = glGetBooleanv(GL_STEREO)
def paintGL(self):
if self.useStereo:
# Left eye fill with yellow
glDrawBuffer(GL_BACK_LEFT)
glClearColor(1, 1, 0, 1)
glClear(GL_COLOR_BUFFER_BIT)
# Right eye fill with cyan
glDrawBuffer(GL_BACK_RIGHT)
glClearColor(0, 1, 1, 1)
glClear(GL_COLOR_BUFFER_BIT)
else:
# Both eyes fill with green
glDrawBuffer(GL_BACK) # both left and right
glClearColor(0, 1, 0, 1)
glClear(GL_COLOR_BUFFER_BIT)
# Attempt to use stereoscopic QGLFormat OpenGL format
# To work, this must be called before MyGLWidget is constructed.
fmt = QGLFormat.defaultFormat()
fmt.setStereo(True)
if fmt.stereo():
print "Quad buffered stereo appears to work(1)"
QGLFormat.setDefaultFormat(fmt)
# The usual Qt hello world boilerplate...
app = QApplication(sys.argv)
win = QMainWindow()
win.setCentralWidget(MyGLWidget(win))
win.show()
sys.exit(app.exec_())
On both computers, all three "Quad buffered stereo appears to work" messages are printed.
On the stereo-ready workstation with a 120Hz stereo monitor, the background of the window appears pale lime green, as it switches between the yellow and cyan colors at 120 Hz. On a 60Hz monitor, it is possible to perceive the seizure-inducing flickering between the two colors. This flickering also appears on the laptop, suggesting that maybe it really does support quad buffered stereo?
One final wrinkle: If I connect the laptop to an external monitor, I see the flickery superposition on the external monitor, but on the laptop screen the window is yellow, i.e. the BACK_LEFT buffer color only. With just the laptop screen or just the external monitor, I observe the flickery phenotype.
Does the GeForce 330M video board really support quad buffered stereo on Mac? Is there a better way to detect a real quadro board from my program?
All Mac computers I have tested support quad buffered stereo. Even those with so-called consumer level (i.e. non-Quadro) video cards. This explains why even my laptop claims to support stereo. Because it does.
To prove that all Macs support quad buffered stereo, I needed 3D hardware that accepts frame sequential stereo without a sync signal. I now have that at my work. And I am viewing beautiful quad-buffered stereo from Mac computers. This is awesome. So why am I unable to find any vendor who sells Mac oriented stereo3D solutions? This beautiful capability is sitting latent on Macs, and nobody seems to realize it is there.