Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Crash with QQuickFrameBufferObject



  • I am trying to create a simple QQuickFrameBufferObject in order to render some custom opengl textures in Qt Quick. So I decided to test it with PySide2. Here is a simple implementation:

    from PySide2.QtQuick import QQuickFramebufferObject
    from PySide2.QtGui import QOpenGLFramebufferObjectFormat, QOpenGLFramebufferObject
    from PySide2.QtCore import QSize, Qt
    
    class FboRenderer(QQuickFramebufferObject.Renderer):
        def __init__(self, parent=None):
            super().__init__(parent)
            print("Creating renderer")
    
        def createFrameBufferObject(self, size):
            format = QOpenGLFramebufferObjectFormat()
            format.setAttachment(QOpenGLFramebufferObject.Depth)
            return QOpenGLFramebufferObject(size, format)
        
        def synchronize(self, item):
            print("Synchronizing")
    
        def render(self):
            print("Rendering")
    
    class OpenGLCanvas(QQuickFramebufferObject):
        def __init__(self, parent=None):
            super().__init__(parent)
        
        def createRenderer(self):
            return FboRenderer()
    

    Then to use this in QML I used:

        qmlRegisterType(OpenGLCanvas,"OpenGLCanvas", 1, 0, "OpenGLCanvas")
    
    import QtQuick 2.12
    import QtQuick.Window 2.12
    import OpenGLCanvas 1.0
    
    Window{
        id: win
        visible: true
    
        OpenGLCanvas{
            anchors.fill: parent
        }
    }
    

    Now the app runs and displays "Creating renderer" but then it crashes after a couple of seconds.



  • Someone has answered this on StackOverflow.



  • Someone has answered this on StackOverflow.


Log in to reply