Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
5.15.2
-
None
Description
When using QOpenGLShaderProgram.setUniformValue() with a parameter other than a single float, the warning is produced and the uniform is not set.
#pmv_matrix is of QtGui.QMatrix4x4 type shader_program.setUniformValue(mvp_matrix_location, pmv_matrix); # <- RuntimeWarning: SbkConverter: Unimplemented C++ array type.
The argument type is mentioned in the documentation: https://doc.qt.io/archives/qtforpython-5.14/PySide2/QtGui/QOpenGLShaderProgram.html#id76
Is there a workaround for this? How to use shaders with PySide2?
- Cannot use PyOpenGL because it is not correctly initialized on some of our clients' machines, even though it did work with PySide(Qt4) https://bugreports.qt.io/browse/QTBUG-42240
- Cannot use QOpenGLFunctions because of the bug (https://bugreports.qt.io/browse/PYSIDE-1511)
- Now I cannot use `setUniformValue`
—
from PySide2 import QtGui from PySide2 import QtCore basic_vertex_shader_source = \ """ attribute highp vec4 vPosition; uniform highp mat4 pmv_matrix; void main() { gl_Position = pmv_matrix * vPosition; } """ basic_fragment_shader_source = \ """ uniform mediump vec4 color; uniform mediump float dumb_float; void main() { gl_FragColor = color; } """ if __name__ == "__main__": app = QtGui.QGuiApplication() off_screen = QtGui.QOffscreenSurface() off_screen.create() if off_screen.isValid(): context = QtGui.QOpenGLContext() if context.create(): context.makeCurrent(off_screen) shader_program = QtGui.QOpenGLShaderProgram(context) shader_program.addShaderFromSourceCode(QtGui.QOpenGLShader.Vertex, basic_vertex_shader_source) shader_program.addShaderFromSourceCode(QtGui.QOpenGLShader.Fragment, basic_fragment_shader_source) shader_program.bind() color = QtGui.QColor(0, 255, 0, 255) wind_rect = QtCore.QRect(0, 0, 80, 60) pmv_matrix = QtGui.QMatrix4x4() pmv_matrix.ortho(wind_rect) mvp_matrix_location = shader_program.attributeLocation("pmv_matrix") color_location = shader_program.attributeLocation("color") float_location = shader_program.attributeLocation("dumb_float") ################ THE ISSUE ##################### shader_program.setUniformValue(mvp_matrix_location, pmv_matrix); # <- RuntimeWarning: SbkConverter: Unimplemented C++ array type. shader_program.setUniformValue(color_location, color); # <- RuntimeWarning: SbkConverter: Unimplemented C++ array type. shader_program.setUniformValue(float_location, 1); # No Warning
Attachments
Issue Links
- duplicates
-
PYSIDE-979 Shiboken: unimplemented c++ array type
- Closed