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

QPainter to QOpenGLWidget doesn't set active texture to texture 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: P2: Important P2: Important
    • None
    • 5.10.1
    • GUI: OpenGL
    • None

      The QPainter which will be painting to QOpenGLWidget doesn't set active texture to texture 0.

      // Following snippet demonstrates the problem - code is in class derived from QOpenGLWidget - method paintGL():
      ...
      
      // Assuming active texture set to other than texture 0
      // e.g. context()->functions()->glActiveTexture(GL_TEXTURE0 + 1);
      
      QPainter painter;
      painter.begin(this);
      
      // context()->functions()->glActiveTexture(GL_TEXTURE0); // Uncomment so that code works
      painter.drawImage(0, 0, m_sceneBitmap);
      painter.end();
      
      ...
      
      

      The problem is painter.begin() assumes that active texture is texture 0, which may not be true. The result is black (or possibly some other) image instead of image which is requested to be drawn.

      Found by inserting painter.beginNativePainting(); painter.endNativePainting(); empty brackets and examining what all it does.

      P.s.: Don't have time to create full reproducer. Examine your code.

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

            lagocs Laszlo Agocs
            filousov Pavel Celba
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes