Created attachment 404130 [details, diff] Enable building of QOpenGLFunctions implementations if USE contains opengl QOpenGLFunctions, exposed via PyQt, provides convenient access to OpenGL API calls without requiring PyOpenGL. Because the PyQt5 ebuild supplies a list of Qt module wrappers to build when calling PyQt5's configure.py script, configure.py does not attempt to guess which modules should be built, preventing automatic discovery of the fact that QOpenGLFunction implementation wrappers should be built. If the PyQt5 ebuild is modified to remove all the --enable* arguments to configure.py, the QOpenGLFunction modules are built. It seems likely to be an oversight that the _QOpenGLFunctions_2_1 and _QOpenGLFunctions_4_1_Core modules are not --enabled when the USE contains "opengl". With the attached patch applied, the following works properly: _GL=None def GL(): global _GL if _GL is None: context = Qt.QOpenGLContext.currentContext() if context is not None: try: _GL = context.versionFunctions() if _GL is None: # Some platforms seem to need version profile specification vp = Qt.QOpenGLVersionProfile() vp.setProfile(Qt.QSurfaceFormat.CompatibilityProfile) vp.setVersion(2, 1) _GL = context.versionFunctions(vp) except ImportError: # PyQt5 v5.4.0 and v5.4.1 provide access to OpenGL functions up to OpenGL 2.0, but we have made # an OpenGL 2.1 context. QOpenGLContext.versionFunctions(..) will, by default, attempt to return # a wrapper around QOpenGLFunctions2_1, which has failed in the try block above. Therefore, # we fall back to explicitly requesting 2.0 functions. We don't need any of the C _GL 2.1 # constants or calls, anyway - these address non-square shader uniform transformation matrices and # specification of sRGB texture formats, neither of which we use. vp = Qt.QOpenGLVersionProfile() vp.setProfile(Qt.QSurfaceFormat.CompatibilityProfile) vp.setVersion(2, 0) _GL = context.versionFunctions(vp) if not _GL: raise RuntimeError('Failed to retrieve OpenGL wrapper namespace.') if not _GL.initializeOpenGLFunctions(): raise RuntimeError('Failed to initialize OpenGL wrapper namespace.') return _GL
Please don't CC arches.
Yeah, looks like I missed those modules. The patch is incomplete however: there are many more _QOpenGLFunctions* modules, and we also need to introduce a gles2 USE flag to build _QOpenGLFunctions_ES2 instead of the full OpenGL modules.
(In reply to Davide Pesavento from comment #2) > Yeah, looks like I missed those modules. > > The patch is incomplete however: there are many more _QOpenGLFunctions* > modules, and we also need to introduce a gles2 USE flag to build > _QOpenGLFunctions_ES2 instead of the full OpenGL modules. Ah, good points. I can probably find some hours this week, and certainly some on the weekend to make a more complete patch. It's a good opportunity to learn more about Portage :)
Don't worry, I already have a fix locally but I didn't have time to test it today so I didn't commit it yet.
Since opengl functionality has been integrated in QtGui with Qt5, I've decided to put the QOpenGLFunctions wrappers behind USE=gui instead of USE=opengl. PyQt5[opengl] instead builds the bindings for the deprecated QtOpenGL module.
Fixed in 5.4.2, sorry for the delay.