示例#1
0
class FrameBufferObject:
    def __init__(self, width, height):
        super().__init__()

        buffer_format = QOpenGLFramebufferObjectFormat()
        buffer_format.setAttachment(QOpenGLFramebufferObject.Depth)
        self._fbo = QOpenGLFramebufferObject(width, height, buffer_format)

        self._contents = None

    ##  Get the texture ID of the texture target of this FBO.
    def getTextureId(self):
        return self._fbo.texture()

    ##  Bind the FBO so it can be rendered to.
    def bind(self):
        self._contents = None
        self._fbo.bind()

    ##  Release the FBO so it will no longer be rendered to.
    def release(self):
        self._fbo.release()

    ##  Get the contents of the FBO as an image data object.
    def getContents(self):
        if not self._contents:
            self._contents = self._fbo.toImage()

        return self._contents
示例#2
0
class QtFrameBufferObject(FrameBufferObject):
    def __init__(self, width, height):
        super().__init__()

        buffer_format = QOpenGLFramebufferObjectFormat()
        buffer_format.setAttachment(QOpenGLFramebufferObject.Depth)
        self._fbo = QOpenGLFramebufferObject(width, height, buffer_format)

        self._contents = None

    def bind(self):
        self._contents = None
        self._fbo.bind()

    def release(self):
        self._fbo.release()

    def getTextureId(self):
        return self._fbo.texture()

    def getContents(self):
        if not self._contents:
            self._contents = self._fbo.toImage()

        return self._contents
示例#3
0
class QtFrameBufferObject(FrameBufferObject):
    def __init__(self, width, height):
        super().__init__()

        buffer_format = QOpenGLFramebufferObjectFormat()
        buffer_format.setAttachment(QOpenGLFramebufferObject.Depth)
        self._fbo = QOpenGLFramebufferObject(width, height, buffer_format)

        self._contents = None

    def bind(self):
        self._contents = None
        self._fbo.bind()

    def release(self):
        self._fbo.release()

    def getTextureId(self):
        return self._fbo.texture()

    def getContents(self):
        if not self._contents:
            self._contents = self._fbo.toImage()

        return self._contents
示例#4
0
class FrameBufferObject:
    def __init__(self, width, height):
        super().__init__()

        buffer_format = QOpenGLFramebufferObjectFormat()
        buffer_format.setAttachment(QOpenGLFramebufferObject.Depth)
        self._fbo = QOpenGLFramebufferObject(width, height, buffer_format)

        self._contents = None

    ##  Get the texture ID of the texture target of this FBO.
    def getTextureId(self):
        return self._fbo.texture()

    ##  Bind the FBO so it can be rendered to.
    def bind(self):
        self._contents = None
        self._fbo.bind()

    ##  Release the FBO so it will no longer be rendered to.
    def release(self):
        self._fbo.release()

    ##  Get the contents of the FBO as an image data object.
    def getContents(self):
        if not self._contents:
            self._contents = self._fbo.toImage()

        return self._contents
示例#5
0
class FrameBufferObject:
    """An interface for OpenGL FrameBuffer Objects.

    This class describes a minimal interface that is expected of FrameBuffer Object
    classes.
    """
    def __init__(self, width: int, height: int) -> None:
        super().__init__()

        buffer_format = QOpenGLFramebufferObjectFormat()
        buffer_format.setAttachment(QOpenGLFramebufferObject.Depth)
        self._fbo = QOpenGLFramebufferObject(width, height, buffer_format)

        self._contents = None

    def getTextureId(self) -> int:
        """Get the texture ID of the texture target of this FBO."""
        return self._fbo.texture()

    def bind(self) -> None:
        """Bind the FBO so it can be rendered to."""
        self._contents = None
        self._fbo.bind()

    def release(self) -> None:
        """Release the FBO so it will no longer be rendered to."""
        self._fbo.release()

    def getContents(self) -> QImage:
        """Get the contents of the FBO as an image data object."""
        if not self._contents:
            self._contents = self._fbo.toImage()

        return self._contents