Draw a QWidget into a FBO or a OpenGL texture
I want to make the rendering of my QWidget into a OpenGL texture. Currently I use the function grab(), convert the result to QImage and get the constData to send it on VRAM. The question is : is it possible to render the QWidget directly on a FBO or glTexture ?
I looking on setRedirected() but this function seem deprecied.
Me again. Still not super with opengl but I wonder if this is something like it
Thanks again ^^
the code below
renderTarget_ = QPixmap(width(), height()); renderTarget_.fill(QColor(0, 0, 0, 0)); QPainter painter(&renderTarget_); render(&painter);
is speeder than this code : widget->grab();
Ok. seems more direct but still not directly on gl texture but I guess its as close as you get :)
@Robinsondesbois Hi! May I ask what this is good for? Maybe there is a better way.
Although this does not work completely for us, it gave us a good starting point:
I need to draw a QMainWindow into an OpenGL texture. The aim is, I want a Qt GUI into a OpenGL scene.
I think the t3685's method is too slow. Too much swap OpenGL context (one per widget I suppose).
If you can switch from QWidgets to QtQuick then there might be a high performance solution: QtQuick scenes are rendered with OpenGL and one can set the render target of a QQuickWindow to an FBO of your choice. You could then use this FBO in your own OpenGL scene. This should be pretty fast as the rendered image of your "3D GUI" would never leave the graphics card's memory.
You're rigth. It seem a good way to solve my problem.