1

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.

Florian Blume
  • 3,237
  • 17
  • 37
  • do you have Alpha buffer in your context? [check the pixelformat](https://stackoverflow.com/a/50248477/2521214) for `cAlphaBits` – Spektre Jun 06 '18 at 05:54
  • 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 Jun 06 '18 at 07:08
  • see [complete GL+VAO/VBO+GLSL+shaders example in C++](https://stackoverflow.com/a/31913542/2521214) 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?](https://stackoverflow.com/q/19099162/2521214) just add /set the stuff in `pfd` you need ... – Spektre Jun 06 '18 at 19:06
  • Hi Spektre, thanks for your reply but I'm on Linux and solved my problem alread ;) See my answer below. – Florian Blume Jun 07 '18 at 08:56
  • 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_ALPHA` – Spektre Jun 07 '18 at 09:51
  • Ok, well I haven't tried to not set it and inspect the result, but right now it works how I wanted it to work :-) – Florian Blume Jun 07 '18 at 11:03

1 Answers1

1

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

Florian Blume
  • 3,237
  • 17
  • 37