aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2019-04-23 14:32:55 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2019-04-24 08:53:51 +0000
commit05ae61cba5f943eb58343b44f8d474bc88bf0ce4 (patch)
tree1e4d1cafcae292a2960275621f3595d8b01c3f9b
parent5cec7b8926fd12daa3bdca72cd2dfaadf5eda4b1 (diff)
Add explicit methods for QOpenGLShaderProgramm.setUniformValue (i/f)
Selecting which overload to use is in hands of the shader program code that defines the type, then it is better to explicitly call signatures that are overloaded using number types, specially for OpenGL. This change will help with PYSIDE-989, because it will allow to call `setUniformValue1f` without having the problem of using the generic `setUniformValue` that will end in calling the wrong method (the integer one). Since the primitive type conversion is a separate global issue, another task has been opened PYSIDE-1000. Task-number: PYSIDE-989 Change-Id: I77e5616e081e570bee880a1a403faf3cf6c55099 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml20
-rw-r--r--sources/pyside2/PySide2/glue/qtgui.cpp10
2 files changed, 30 insertions, 0 deletions
diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
index cf01b234a..cadfc33fa 100644
--- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
+++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml
@@ -2905,6 +2905,26 @@
<modify-function signature="setUniformValueArray(const char*,const unsigned int*,int)">
<modify-argument index="2"><array/></modify-argument>
</modify-function>
+ <!-- Add explicit signatures for the setUniformValue functions -->
+ <modify-function signature="setUniformValue(const char*, GLfloat)" remove="all"/>
+ <modify-function signature="setUniformValue(const char*, GLint)" remove="all"/>
+ <modify-function signature="setUniformValue(const char*, GLuint)" remove="all"/>
+ <modify-function signature="setUniformValue(int, GLfloat)" remove="all"/>
+ <modify-function signature="setUniformValue(int, GLint)" remove="all"/>
+ <modify-function signature="setUniformValue(int, GLuint)" remove="all"/>
+ <!-- No need for a signature for GLuint, since Qt (internally) calls the same function: glUniform1i -->
+ <add-function signature="setUniformValue1f(const char*, float)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_float"/>
+ </add-function>
+ <add-function signature="setUniformValue1i(const char*, int)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_int"/>
+ </add-function>
+ <add-function signature="setUniformValue1f(int, float)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_float"/>
+ </add-function>
+ <add-function signature="setUniformValue1i(int, int)" return-type="void">
+ <inject-code file="../glue/qtgui.cpp" snippet="qopenglshaderprogram_setuniformvalue_int"/>
+ </add-function>
</object-type>
<object-type name="QOpenGLTexture" since="5.2">
<enum-type name="BindingTarget"/>
diff --git a/sources/pyside2/PySide2/glue/qtgui.cpp b/sources/pyside2/PySide2/glue/qtgui.cpp
index 4ae3eef75..aef9e4b59 100644
--- a/sources/pyside2/PySide2/glue/qtgui.cpp
+++ b/sources/pyside2/PySide2/glue/qtgui.cpp
@@ -115,6 +115,16 @@ if (doc) {
}
// @snippet qtextblock-userdata
+// @snippet qopenglshaderprogram_setuniformvalue_float
+float value = %2;
+%CPPSELF.setUniformValue(%1, value);
+// @snippet qopenglshaderprogram_setuniformvalue_float
+
+// @snippet qopenglshaderprogram_setuniformvalue_int
+int value = %2;
+%CPPSELF.setUniformValue(%1, value);
+// @snippet qopenglshaderprogram_setuniformvalue_int
+
// @snippet qpolygon-reduce
PyObject *points = PyList_New(%CPPSELF.count());
for (int i = 0, i_max = %CPPSELF.count(); i < i_max; ++i){