I have created two instances of Squircle(openglunderqml) item
First instance have size 500,500 alignment in center to screen
ex:Mini Player in preview
Second instance have size of screen size alignment to complete screen
ex:Main Player in viewer
Initially Main Player does noting will goto preview there we can see mini player user say ok will launch main player
But during preview I could not see mini player because main player glviewport covering complete screen and its clearing because paint is getting alway its is connected to beforeRendering signal
code:
http://doc.qt.io/qt-5/qtquick-sceneg...l-example.html
I followed above link and made small change glviewport according to instance boundary
glViewport(m_viewportSize.x(), m_viewportSize.y(), m_viewportSize.width(), m_viewportSize.height());
glViewport(m_viewportSize.x(), m_viewportSize.y(), m_viewportSize.width(), m_viewportSize.height());
To copy to clipboard, switch view to plain text mode
glclear update
glClearColor(0, 0, 0, 1);
glScissor(m_ViewportSize.x(),m_ViewportSize.y(), m_ViewportSize.width(), m_ViewportSize.height());
glEnable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
glClearColor(0, 0, 0, 1);
glScissor(m_ViewportSize.x(),m_ViewportSize.y(), m_ViewportSize.width(), m_ViewportSize.height());
glEnable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);
To copy to clipboard, switch view to plain text mode
main.qml
import QtQuick 2.0
import OpenGLUnderQML 1.0
Item {
width: 1200
height: 600
Test{
width: 500
height: 500
anchors.centerIn: parent
color: "green"
}
Test{
width: parent.width
height: parent.height
anchors.top: parent.top
anchors.left: parent.left
color: "red"
}
}
import QtQuick 2.0
import OpenGLUnderQML 1.0
Item {
width: 1200
height: 600
Test{
width: 500
height: 500
anchors.centerIn: parent
color: "green"
}
Test{
width: parent.width
height: parent.height
anchors.top: parent.top
anchors.left: parent.left
color: "red"
}
}
To copy to clipboard, switch view to plain text mode
Test.qml
import QtQuick 2.0
import OpenGLUnderQML 1.0
Rectangle {
opacity: 0.2
Squircle {
SequentialAnimation on t {
NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
loops: Animation.Infinite
running: true
}
}
//! [1] //! [2]
Rectangle {
color: Qt.rgba(1, 1, 1, 0.7)
radius: 10
border.width: 1
border.color: "white"
anchors.fill: label
anchors.margins: -10
}
Text {
id: label
color: "black"
wrapMode: Text.WordWrap
text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML"
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: 20
}
}
import QtQuick 2.0
import OpenGLUnderQML 1.0
Rectangle {
opacity: 0.2
Squircle {
SequentialAnimation on t {
NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad }
NumberAnimation { to: 0; duration: 2500; easing.type: Easing.OutQuad }
loops: Animation.Infinite
running: true
}
}
//! [1] //! [2]
Rectangle {
color: Qt.rgba(1, 1, 1, 0.7)
radius: 10
border.width: 1
border.color: "white"
anchors.fill: label
anchors.margins: -10
}
Text {
id: label
color: "black"
wrapMode: Text.WordWrap
text: "The background here is a squircle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML"
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.margins: 20
}
}
To copy to clipboard, switch view to plain text mode
[/code]
Bookmarks