Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QGraphicsView and QGLFramebufferObject: render with alpha channel
Peter K last edited by
I am rendering a 3D world and want to render the contents of a QGraphicsView on top of it. The render process is done in a specialized render thread. The rendering of a QWidget can not be done in this thread, as it has to be done in the GUI thread. For this reason I want to render a QWidget onto the texture of a QGLFramebufferObject. This texture will be used later as an overlay, on top of the 3D rendering, using native OpenGL calls.
Assume the threadsafety has been managed.
The problem is that the alpha channel of the texture is not used. This means that any transparent components of the widget cannot blended correctly. From what I've seen, the alpha channel is set to 1, as OpenGL blending renders the overlay opaque.
I render the widget using the following (sample) code:
// Somewhere in an init function
fbo = new QGLFramebufferObject(800, 600, QGLFramebufferObject::CombinedDepthStencil);
// The paintEvent funtion of the QGraphicsView
// (GUI thread)
// Final render function
// (Render thread)