The following simple code outputs just None
twice, what could be the reason for that? I can see black window, but cannot draw anything since have no access to GL functions.
下面的简单代码两次都不输出,这是什么原因呢?我可以看到黑色的窗口,但是不能画任何东西,因为我不能访问GL函数。
from PyQt5.QtGui import QOpenGLWindow
from PyQt5.QtWidgets import QApplication
import sys
class MainWindow(QOpenGLWindow):
def paintGL(self):
print self.context().versionFunctions()
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
1 个解决方案
#1
0
I found a very nice example here: https://github.com/pbouda/stuff/blob/master/opengl/pyqt/chocolux.py
我在这里找到了一个很好的例子:https://github.com/pbouda/stuff/blob/master/opengl/pyqt/chocolux.py。
The issue was in incorrect GL profile: despite the fact that my video card has 4.4, PyQt supports only 2.0 and 2.1. That is sad to be honest...
问题出现在错误的GL配置文件中:尽管我的视频卡有4.4,PyQt只支持2.0和2.1。老实说,这真令人难过……
1.0 failed: No module named _QOpenGLFunctions_1_0
1.1 failed: No module named _QOpenGLFunctions_1_1
1.2 failed: No module named _QOpenGLFunctions_1_2
1.3 failed: No module named _QOpenGLFunctions_1_3
1.4 failed: No module named _QOpenGLFunctions_1_4
1.5 failed: No module named _QOpenGLFunctions_1_5
2.0 is ok
2.1 is ok
3.0 failed: No module named _QOpenGLFunctions_3_0
3.1 failed: No module named _QOpenGLFunctions_3_1
I got this with the following code:
我得到了以下代码:
def paintGL(self):
for i in xrange(0, 5):
for j in xrange(0, 1000):
version = QtGui.QOpenGLVersionProfile()
version.setVersion(i, j)
try:
if self.context().versionFunctions(version) is not None: print '{}.{} is ok'.format(i, j)
except Exception as e:
print '{}.{} failed: {}'.format(i, j, e)
#1
0
I found a very nice example here: https://github.com/pbouda/stuff/blob/master/opengl/pyqt/chocolux.py
我在这里找到了一个很好的例子:https://github.com/pbouda/stuff/blob/master/opengl/pyqt/chocolux.py。
The issue was in incorrect GL profile: despite the fact that my video card has 4.4, PyQt supports only 2.0 and 2.1. That is sad to be honest...
问题出现在错误的GL配置文件中:尽管我的视频卡有4.4,PyQt只支持2.0和2.1。老实说,这真令人难过……
1.0 failed: No module named _QOpenGLFunctions_1_0
1.1 failed: No module named _QOpenGLFunctions_1_1
1.2 failed: No module named _QOpenGLFunctions_1_2
1.3 failed: No module named _QOpenGLFunctions_1_3
1.4 failed: No module named _QOpenGLFunctions_1_4
1.5 failed: No module named _QOpenGLFunctions_1_5
2.0 is ok
2.1 is ok
3.0 failed: No module named _QOpenGLFunctions_3_0
3.1 failed: No module named _QOpenGLFunctions_3_1
I got this with the following code:
我得到了以下代码:
def paintGL(self):
for i in xrange(0, 5):
for j in xrange(0, 1000):
version = QtGui.QOpenGLVersionProfile()
version.setVersion(i, j)
try:
if self.context().versionFunctions(version) is not None: print '{}.{} is ok'.format(i, j)
except Exception as e:
print '{}.{} failed: {}'.format(i, j, e)