Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. QGLBuffer.allocate messes with QGLWidget.renderText
Qt 6.11 is out! See what's new in the release blog

QGLBuffer.allocate messes with QGLWidget.renderText

Scheduled Pinned Locked Moved Language Bindings
2 Posts 1 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    srossross
    wrote on last edited by
    #1

    When I call QGLBuffer.allocate QGLWidget.renderText stops working entirely. (simplest demo of issue)

    • In fact all QPainter functionality stops working, even if you overload the QGLwidget.paintEvent method.
    • Even native openGL calls to allocate a VBO cause this issue to persist. eg. @glBufferData@

    The following PySide code demonstrates the issue. It will open two QGLwidget windows:

    • One window calls QGLBuffer.allocate and you can not see the text.
    • The other works fine.

    Code:
    @
    from PySide.QtGui import *
    from PySide.QtOpenGL import *
    from OpenGL.GL import *
    import sys

    class GLWidget(QGLWidget):
    
        def __init__(self, alloc=False):
            QGLWidget.__init__(self)
            self.alloc = alloc
            
        def initializeGL(self):
            self.buffer = buffer = QGLBuffer(QGLBuffer.VertexBuffer)
            buffer.create()
            buffer.bind()
            buffer.setUsagePattern(QGLBuffer.StaticDraw)
            
            if self.alloc: # If true text will not be drawn
                buffer.allocate(80)
        
        def resizeGL(self, h, w):
            glViewport(0, 0, h, w)
            
        def paintGL(self):
            
            glClearColor(1, 1, 1, 1)
            glClear(GL_COLOR_BUFFER_BIT)
            
            glColor(0, 0, 0, 1)
            self.renderText(50, 50, "Text to Render")
    
    def main(argv):
    
        app = QApplication(argv)
        
        widget = GLWidget(alloc=True)
        widget.show()
        
        widget2 = GLWidget(alloc=False)
        widget2.show()
        
        app.exec_()
        
    if __name__ == '__main__':
        main(sys.argv)
    

    @

    Can anyone point me in the right direction?

    Thanks in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      srossross
      wrote on last edited by
      #2

      Solved it. I needed to call QGLBuffer.release() before calls to QPainter.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved