Can I transform a QQuickFramebufferObject background?

I am using QQuickFramebufferObject in QML to draw OpenGL code. I found a couple of ways to make OpenGL with QML, one of which (in the Qt Squircle example) is to draw all OpenGLs either below everything or above everything, but I use the QQuickFramebufferObject method because I need regular QML objects like above and below the object created by OpenGL.

All OpenGL code works fine. The background of the QQuickFramebufferObject must be transparent so that QML objects can be seen. (My QQuickFramebufferObject draws an abstract shape.) However, QQuickFramebufferObject seems to lock its rectangle on the screen and show nothing below it. I tried

glClearColor( 0.0, 0.0, 0.0, 0.0f ); glClear( GL_COLOR_BUFFER_BIT ); 

so that the background is transparent, but instead I just got a white rectangle. Even if I miss the call to FBO rendering as a whole, it still draws everything, so I think this is something outside of OpenGL code and how QML handles FBO.

What I want:

What I want

What I get:

enter image description here

+5
source share
1 answer

I realized this was not a mistake with FBO, but with Rectangle. I never set its color, since I use it only as a holder for other objects, which is white by default and not transparent. I changed it as a color: "transparent", and now everything is fine.

+2
source

Source: https://habr.com/ru/post/1240116/


All Articles