Reputation: 2040
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.
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_())
Upvotes: 1
Views: 1367
Reputation: 2040
I found a very nice example here: 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...
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)
Upvotes: 2