Getting OpenGL context newer than 2.1 with Qt 4 and Mavericks

≯℡__Kan透↙ 提交于 2019-12-13 00:10:59

问题


I'm having difficulty creating an OpenGL context newer than 2.1 (Mac OS 10.9.1, Qt 4.8.5, PySide 1.2.1). Minimal example code is given below; it produces a 2.1 context rather than 3.2 or higher.

The code is based on this tutorial; the tutorial's sample C++ code also fails when run on my machine.

This issue might be related to this bug: QGLFormat.openGLVersionFlags() returns 0x7f (indicating compatability up to OpenGL 2.1 but no later).

Is there something that I'm missing, or is it hopeless until that bug is fixed?

from PySide import QtGui, QtOpenGL
from OpenGL.GL import *

class Canvas(QtOpenGL.QGLWidget):
    def __init__(self, parent=None):
        format = QtOpenGL.QGLFormat()
        format.setVersion(3, 2)
        format.setProfile(QtOpenGL.QGLFormat.CoreProfile)
        super(Canvas, self).__init__(format, parent)

    def initializeGL(self): print glGetString(GL_VERSION)

    def paintGL(self):      pass

if __name__ == '__main__':
    app = QtGui.QApplication("test")
    canvas = Canvas()
    canvas.show()
    app.exec_()

来源:https://stackoverflow.com/questions/21971403/getting-opengl-context-newer-than-2-1-with-qt-4-and-mavericks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!