Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 550606 - dev-python/PyQt5-5.4.1 - build _QOpenGLFunctions* wrapper modules
Summary: dev-python/PyQt5-5.4.1 - build _QOpenGLFunctions* wrapper modules
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Qt Bug Alias
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: pyqt5-stable
  Show dependency tree
 
Reported: 2015-05-28 00:26 UTC by Erik Hvatum
Modified: 2015-06-19 17:51 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Enable building of QOpenGLFunctions implementations if USE contains opengl (enable_PyQt5_QOpenGLFunctions_modules.patch,588 bytes, patch)
2015-05-28 00:26 UTC, Erik Hvatum
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Hvatum 2015-05-28 00:26:05 UTC
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
Comment 1 Davide Pesavento (RETIRED) gentoo-dev 2015-05-29 00:55:20 UTC
Please don't CC arches.
Comment 2 Davide Pesavento (RETIRED) gentoo-dev 2015-06-03 14:07:50 UTC
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.
Comment 3 Erik Hvatum 2015-06-03 17:48:12 UTC
(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 :)
Comment 4 Davide Pesavento (RETIRED) gentoo-dev 2015-06-04 02:14:30 UTC
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.
Comment 5 Davide Pesavento (RETIRED) gentoo-dev 2015-06-19 17:50:42 UTC
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.
Comment 6 Davide Pesavento (RETIRED) gentoo-dev 2015-06-19 17:51:49 UTC
Fixed in 5.4.2, sorry for the delay.