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

QOpenGLShaderProgram setAttributeArray methods are either incorrectly implemented, incorrectly documented or both

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.3.1
    • GUI: OpenGL
    • None

    Description

      According to the source code of QOpenGLShaderProgram a call of a setAttributeArray(...) method directly translates to a call of glVertexAttribPointer() whose "pointer" parameter is set to the adress of the data that was submitted to the setAttributeArray method (ie. an address in the system memory). Whereas according to the official OpenGL documentation this pointer parameter is only meant to be an offset inside of a buffer object. Some drivers allow this pointer to be a pointer to data in the system memory (eg. Nvidia Geforce drivers) but to my experience others crash when you do this (eg. Intel HD graphics, Nvidia Quadro). According to the the official OpenGL documentation (https://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttribPointer.xml) this function is simply not meant to be used in this way. Still exactly this wrong use of the Qt method is shown in the simple example in the Qt documentation of the QOpenGLShaderProgram class. Also the documentation of the setAttributeArray method says nothing about creating a buffer first.
      In my opinion there are two possible ways to fix this:

      1. Change the documentation of the class and method and the example to clarify that you have to create a buffer object first and set the pointer in the glVertexAttribPointer call to NULL or
      2. Change the implementation to automatically create a buffer object in the background and fill it with the provided data (eg. using glBufferData)

      At the moment these Qt methods with their signatures make no sense at all on the hardware I listed above.

      I attached some source code that wraps the example of the documentation in a simple OpenGLWindow and runs fine on my GTX660 with the latest GeForce drivers but crashes on a Workstation with a (Quadro) NVS300 card and a laptop with Intel HD graphics 4400.

      Attachments

        1. main.cpp
          1 kB
        2. openglwindow.cpp
          4 kB
        3. openglwindow.h
          0.7 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            w1th0utnam3 Fabian Löschner
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes