PDA

View Full Version : Question about the example “Scene Graph - OpenGL Under QML”



stereoMatching
26th June 2013, 22:32
How could I apply the effect on a specific component?



//! [1]
import QtQuick 2.0
import OpenGLUnderQML 1.0

Item {

width: 320
height: 480

//! [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

//apply the Squircle effect on the Rectangle rather than the root item
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
}
}
}

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
}
}
//! [2]


No matter waht I try, it is always render on the background but not the Rectangle

wysota
26th June 2013, 22:35
No matter waht I try, it is always render on the background but not the Rectangle
That's the point of the whole approach, isn't it?

stereoMatching
26th June 2013, 23:19
That's the point of the whole approach, isn't it?
You are correct, my fault, didn't understand the example.

We could use QGLWidget to render the texture and show it by old widget
what if we want to render a texture but show it by qml scene by c++?
There are some algorithms need to be done by c++(sorting, etc)

wysota
26th June 2013, 23:31
I don't understand what you mean. If you want to show an image using QML then use the Image element. Other than that you can always implement a custom QQuickItem and render whatever you want there using whatever scene graph has to offer.

stereoMatching
27th June 2013, 00:53
I don't understand what you mean. If you want to show an image using QML then use the Image element. Other than that you can always implement a custom QQuickItem and render whatever you want there using whatever scene graph has to offer.
Sorry I didn't explain what I want to do clearly.
What I want to do is very similar to QGLWidget do

create a widget, render the texture by opengl and show it on the widget

I want to do the same thing on the qml too
If it is possible, I would like to create a qml component
which could show the image after render by opengl on the qml site

The example of “Scene Graph - OpenGL Under QML” would render all of the background
but that is not what I want to do

pseudo codes


Rectangle{

//......other components

//render the source by opengl, the result only apply on the GLImage, not the whole background
GLImage{

source: "file:///users/downloads/jjj.png"
//.....

}

//....other components
}

wysota
27th June 2013, 06:27
As I said, you need to create a custom item that will render to an FBO and then display contents of that FBO. Alternatively you can render directly to the item.

stereoMatching
27th June 2013, 11:25
As I said, you need to create a custom item that will render to an FBO and then display contents of that FBO. Alternatively you can render directly to the item.
Thanks, but I have a hard time with FBO

http://www.qtcentre.org/threads/55103-Do-offscreen-render%28openGL%29-with-Qt5
can't find the bug

edit: I found the examples which maybe could solve my problem, "Scene graph-Rendering", thanks for your help