Exemplo n.º 1
0
def createWindow():
    view = QQuickView()
    view.setSurfaceType(QSurface.OpenGLSurface)

    fmt = QSurfaceFormat()
    fmt.setAlphaBufferSize(8)
    fmt.setRenderableType(QSurfaceFormat.OpenGL)
    view.setFormat(fmt)

    color = QColor()
    color.setRedF(0.0)
    color.setGreenF(0.0)
    color.setBlueF(0.0)
    color.setAlphaF(0.0)
    view.setColor(color)

    view.setClearBeforeRendering(True)
    view.setFlags(Qt.FramelessWindowHint | Qt.ToolTip
                  | Qt.WindowStaysOnTopHint)

    context = view.rootContext()

    return (view, context)
Exemplo 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_())
Exemplo n.º 3
0
from _002_2d_triangle.triangle import TriangleUnderlay

if __name__ == '__main__':
    # Not working in Ubuntu 16.04, result in 1282 error for simple calling like glViewport(...)
    if platform.uname().system == 'Darwin':
        f = QSurfaceFormat()
        f.setVersion(4, 1)
        f.setDepthBufferSize(1)  # fix depth buffer error
        f.setStencilBufferSize(1)  # fix stencil buffer error

        # If CoreProfile is used, all the other QML rendering will fail, because they only use 2.1
        f.setProfile(QSurfaceFormat.CompatibilityProfile)
        QSurfaceFormat.setDefaultFormat(f)

    qmlRegisterType(TriangleUnderlay, 'OpenGLUnderQml', 1, 0,
                    'TriangleUnderlay')

    app = QGuiApplication(sys.argv)

    view = QQuickView()
    view.setFormat(f)
    view.setPersistentSceneGraph(True)
    view.setPersistentOpenGLContext(True)
    view.setResizeMode(QQuickView.SizeRootObjectToView
                       )  # Set for the object to resize correctly
    view.setSource(QUrl('TriangleWindow.qml'))
    view.show()

    app.exec()
Exemplo n.º 4
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_())
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))
            else:
                glClearBufferfv(GL_COLOR, 0, (.5, 1, .5, 1))
Exemplo n.º 6
0
from read_conf import confList, create_qml
from PyQt5 import Qt
from tray_icon import TrayIcon
from settingWindow import SettingWindow
import subprocess

if __name__=="__main__":
        app = QApplication(sys.argv)
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        view = QQuickView()
        view.setFlags(Qt.Qt.FramelessWindowHint)

        surface_format = QSurfaceFormat()
        surface_format.setAlphaBufferSize(8)
        view.setFormat(surface_format)

        view.setColor(QColor(0, 0, 0, 0))
        view.setResizeMode(QQuickView.SizeRootObjectToView)

        create_qml()
        t_icon=TrayIcon()
        sw=SettingWindow()
def show_window():
        path='screen.qml'
        view.engine().quit.connect(app.quit)
        view.setSource(QUrl(path))
        desktop=QApplication.desktop()
        x=(desktop.width()-1000)/2
#        x=300#here x=300 because desktop.width may got wrong value due to the bug of qt
        y=(desktop.height() - 100)/2