1
votes

Due to the bad performance (high CPU usage) in my Qt3DOffscreenRenderer, which uses the Qt3D framework, I implemented a new offscreen renderer using only/mostly OpenGL.

Unfortunately, I can't get the object drawn on top of the background image to be transparent. I enabled blending and set glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);.

The result is the following:

enter image description here

What you can't see is that the Qt logo's pixels' alpha is 0.5.

For reference, this is the image without transparency:

enter image description here

I simply want the Qt logo to be a bit transparent, like so:

enter image description here

I managed to create this image using this example and modifing it to use the blend function mentioned above and an alpha value of 0.5 in the shader.

How can I achieve this for the offscreen renderer? I experimented with a lot of parameters but had no luck.

1
do you have Alpha buffer in your context? check the pixelformat for cAlphaBitsSpektre
No luck with either suggestion. Inspecting the format of the renderer of the last image even shows that it doesn't have an alpha buffer enabled. I even set the format of the renderer on my offscreen renderer but this still produces the same result.Florian Blume
see complete GL+VAO/VBO+GLSL+shaders example in C++ and look for int gl_init(HWND Handle); function how to set pixelformat. However the GL implementation of yours can refuse it and chose closest format to what you set up ... I usually got an ordered que of formats (decreasing quality) and chose the first that is accepted like this: What is the proper OpenGL initialisation on Intel HD 3000? just add /set the stuff in pfd you need ...Spektre
Hi Spektre, thanks for your reply but I'm on Linux and solved my problem alread ;) See my answer below.Florian Blume
I did see it. just take in mind that by discarding the alpha channel in your answer you can not use GL_DST_ALPHA nor GL_ONE_MINUS_DST_ALPHASpektre

1 Answers

1
votes

The problem was that I set the internal texture format of the QFramebufferObjectFormat to GL_RGBA32F but it needs to be GL_RGB32F (i.e. without the alpha channel).