QGLBuffer.allocate messes with QGLWidget.renderText



  • 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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.