Issue #1260: Added exception to checkOpenGLVersion to highlight OpenGL ES incompatibility on Raspberry Pi (#1264)
* checkOpenGLVersion exception for OpenGL ES * checkOpenGLVersion exception * checkOpenGLVersion exception * python 2/3 compatibility * Refactoring checkOpenGLVersion Since the original goal of `checkOpenGLVersion` is to re-throw an exception or notify the user about a wrong OpenGL version in another exception, this commit unifies the two exception messages from `checkOpenGLVersion`. Further, it corrects ">" to ">=" in the error message (originally my fault). And it corrects verNumber to be an integer and not a boolean (there was a " < 2" too much at the end of the line). Finally, since the opportunity was there, the method is further refactored, comments and a docstring are added. Co-authored-by: 2xB <2xb@users.noreply.github.com>
This commit is contained in:
parent
e5a1327041
commit
f81768ac59
@ -425,15 +425,35 @@ class GLViewWidget(QtOpenGL.QGLWidget):
|
||||
self.keyTimer.stop()
|
||||
|
||||
def checkOpenGLVersion(self, msg):
|
||||
## Only to be called from within exception handler.
|
||||
ver = glGetString(GL_VERSION).split()[0]
|
||||
if int(ver.split(b'.')[0]) < 2:
|
||||
from .. import debug
|
||||
debug.printExc()
|
||||
raise Exception(msg + " The original exception is printed above; however, pyqtgraph requires OpenGL version 2.0 or greater for many of its 3D features and your OpenGL version is %s. Installing updated display drivers may resolve this issue." % ver)
|
||||
else:
|
||||
raise
|
||||
|
||||
"""
|
||||
Give exception additional context about version support.
|
||||
|
||||
Only to be called from within exception handler.
|
||||
As this check is only performed on error,
|
||||
unsupported versions might still work!
|
||||
"""
|
||||
|
||||
# Check for unsupported version
|
||||
verString = glGetString(GL_VERSION)
|
||||
ver = verString.split()[0]
|
||||
# If not OpenGL ES...
|
||||
if str(ver.split(b'.')[0]).isdigit():
|
||||
verNumber = int(ver.split(b'.')[0])
|
||||
# ...and version is supported:
|
||||
if verNumber >= 2:
|
||||
# OpenGL version is fine, raise the original exception
|
||||
raise
|
||||
|
||||
# Print original exception
|
||||
from .. import debug
|
||||
debug.printExc()
|
||||
|
||||
# Notify about unsupported version
|
||||
raise Exception(
|
||||
msg + "\n" + \
|
||||
"pyqtgraph.opengl: Requires >= OpenGL 2.0 (not ES); Found %s" % verString
|
||||
)
|
||||
|
||||
def readQImage(self):
|
||||
"""
|
||||
Read the current buffer pixels out as a QImage.
|
||||
|
Loading…
Reference in New Issue
Block a user