Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18982

QGLShaderProgram example in Qt documentation wrong

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.8.x
    • 4.7.2, 4.7.3, 4.8.x
    • Documentation
    • None
    • 41287c411cb4b1019d12a49ddf7a738174a42f25

    Description

      This is the vertex shader program example in the qt documentation:
      program.addShaderFromSourceCode(QGLShader::Vertex,
      "attribute highp vec4 vertex;\n"
      "attribute mediump mat4 matrix;\n"
      "void main(void)\n"
      "

      {\n" " gl_Position = matrix * vertex;\n" "}

      ");
      The matrix should be uniform -> "uniform mediump mat4 matrix;\n"

      Then a uniform location has to be querieed:
      old: "int matrixLocation = program.attributeLocation("matrix");"
      new: "int matrixLocation = program.uniformLocation("matrix");"

      Without these changes, the example doesn't work, because later in the code "matrix" is set as uniform value.
      "program.setUniformValue(matrixLocation, pmvMatrix);"

      Also you should consider renaming "matrix" to "ModelViewProjectionMatrix"

      Attachments

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

        Activity

          People

            boddie David Boddie (Inactive)
            bomb3rman Fabian Bumberger
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes