diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-13 21:45:24 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-03-17 14:59:03 +0100 |
commit | 4621b1afab446e5171af0f10ab6ae987dc4c6ff7 (patch) | |
tree | 9e9269f2c55e7ee31cbb0da4148fab5c165fc161 | |
parent | 4001a6b3ffd264bf54d99ffed88d91280676a44f (diff) |
PySide2: Implement QOpenGLContext.versionFunctions()
Forward the call to QOpenGLVersionFunctionsFactory.get().
Fixes: PYSIDE-955
Change-Id: I17df7784acdf1311c4c22c54537620bcc9d2a3b2
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r-- | sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml | 4 | ||||
-rw-r--r-- | sources/pyside2/PySide2/glue/qtgui.cpp | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml index 2a5a905ba..e55d40eb9 100644 --- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml +++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml @@ -2601,6 +2601,10 @@ </object-type> <object-type name="QOpenGLContext"> <enum-type name="OpenGLModuleType"/> + <modify-function signature="versionFunctions(const QOpenGLVersionProfile&) const"> + <inject-code class="target" position="beginning" file="../glue/qtgui.cpp" + snippet="qopenglcontext-versionfunctions"/> + </modify-function> </object-type> <object-type name="QOpenGLContextGroup" since="5.0"/> <object-type name="QOpenGLDebugLogger" since="5.1"> diff --git a/sources/pyside2/PySide2/glue/qtgui.cpp b/sources/pyside2/PySide2/glue/qtgui.cpp index 43185ba9b..d96e9f78f 100644 --- a/sources/pyside2/PySide2/glue/qtgui.cpp +++ b/sources/pyside2/PySide2/glue/qtgui.cpp @@ -23,6 +23,27 @@ * INJECT CODE ********************************************************************/ +// @snippet qopenglcontext-versionfunctions + +// %CPPSELF.%FUNCTION_NAME(%1, %2); Pretend to shiboken we call the function + +// Import QtOpenGLFunctions and call the factory function +// QOpenGLVersionFunctionsFactory.get() +PyObject *module = PyImport_ImportModule("PySide2.QtOpenGLFunctions"); +if (module == nullptr) + return nullptr; +PyObject *loc = PyModule_GetDict(module); +static PyObject *const factoryName = + Shiboken::String::createStaticString("QOpenGLVersionFunctionsFactory"); +auto factory = PyDict_GetItem(loc, factoryName); +if (factory == nullptr) + return nullptr; + +static PyObject *const getMethod = Shiboken::String::createStaticString("get"); +%PYARG_0 = PyObject_CallMethodObjArgs(factory, getMethod, pyArgs[0], %PYSELF, + nullptr); +// @snippet qopenglcontext-versionfunctions + // @snippet glgetshadersource GLsizei bufSize = 4096; GLsizei length = bufSize - 1; |