Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1516

QOpenGLShaderProgram.setUniformValue() - RuntimeWarning: SbkConverter: Unimplemented C++ array type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.15.2
    • PySide
    • None
    • All

    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?

       —

      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

        1. uniform_is_not_set.py
          2 kB
        2. pyside1516.py
          2 kB
        3. pyside1516_diag.diff
          0.9 kB
        4. pyside1516_color.py
          3 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              oortjacek Jacek Drewniak
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes