Ejemplo n.º 1
0
            invt = 1 - t

            pos = invt * invt * invt * self._p1 \
                    + 3 * invt * invt * t * self._p2 \
                    + 3 * invt * t * t * self._p3 \
                    + t * t * t * self._p4

            vertices[i].set(pos.x() * w, pos.y() * h)

        self._root_node.markDirty(QSGNode.DirtyGeometry)

        return self._root_node


if __name__ == '__main__':
    import sys

    app = QGuiApplication(sys.argv)

    qmlRegisterType(BezierCurve, "CustomGeometry", 1, 0, "BezierCurve")

    view = QQuickView()
    format = view.format()
    format.setSamples(16)
    view.setFormat(format)

    view.setSource(QUrl('qrc:///scenegraph/customgeometry/main.qml'))
    view.show()

    sys.exit(app.exec_())
Ejemplo n.º 2
0
            invt = 1 - t

            pos = invt * invt * invt * self._p1 \
                    + 3 * invt * invt * t * self._p2 \
                    + 3 * invt * t * t * self._p3 \
                    + t * t * t * self._p4

            vertices[i].set(pos.x() * w, pos.y() * h)

        self._root_node.markDirty(QSGNode.DirtyGeometry)

        return self._root_node


if __name__ == '__main__':
    import sys

    app = QGuiApplication(sys.argv)

    qmlRegisterType(BezierCurve, "CustomGeometry", 1, 0, "BezierCurve")

    view = QQuickView()
    format = view.format()
    format.setSamples(16)
    view.setFormat(format)

    view.setSource(QUrl('qrc:///scenegraph/customgeometry/main.qml'))
    view.show()

    sys.exit(app.exec_())
                "GlFboViewportAdapter")

## USAGE EXAMPLE #######################################################################################################
if __name__ == "__main__":
    import sys
    from PyQt5.QtCore import QUrl
    from PyQt5.QtGui import QGuiApplication, QSurfaceFormat
    from PyQt5.QtQuick import QQuickView
    from OpenGL.GL import *

    # create an app, create a window with sample qml
    app = QGuiApplication(sys.argv)
    view = QQuickView(QUrl.fromLocalFile("qquickitem_glfbo_sample.qml"))

    # specify OpenGL context version
    oglFormat = view.format()
    oglFormat.setProfile(QSurfaceFormat.CoreProfile)
    oglFormat.setVersion(3, 3)
    view.setFormat(oglFormat)

    # define our viewport
    class HelloGLWorld(GlFboViewportI):
        def __init__(self):
            self.frameCount = 0

        def Cleanup(self):
            pass

        def Draw(self, fboName: int, viewSize: QPoint):
            if self.frameCount % 100 > 50:
                glClearBufferfv(GL_COLOR, 0, (1, .5, .5, 1))