PDA

View Full Version : Viewport overlap issue for multiple instance of openglunderqml causes erasing other



jeggu
10th March 2016, 12:37
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-scenegraph-openglunderqml-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());


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);

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"
}
}

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
}
}

[/code]

mohan
27th June 2018, 12:06
Hi,

Were you able to fix the issue? Even I was trying to do the same and hence while searching on google I came across your post. If you have found the solution please let me know.

Thanks in advance,
Mohan