1 year ago
#159470
Tom Boddington
Device-agnostic context for rendering with OpenGL in Qt
I have some code that uses QPainter to render to a QWidget, QImage or QPrinter, since each is derived from QPaintDevice, like this:
void RenderWithQPainter (QPaintDevice* device)
{
QPainter painter (device);
painter->doThis();
painter->doThat();
}
void RenderToImage (QImage* image)
{
RenderWithQPainter (image);
}
void RenderToWidget (QWidget* widget)
{
RenderWithQPainter (widget);
}
void RenderToPrinter (QPrinter* printer)
{
RenderWithQPainter (printer);
}
Now though, I want to use OpenGL. I know how to render into a QOpelGLWidget but I'd like my code to remain device-agnostic. So what can I render into that I can then copy to the various devices? Is there something I could derive from each of QWidget, QImage and QPrinter, not necessarily a Qt class, which I could render to using OpenGL commands instead of QPainter?
c++
qt
opengl
qwidget
qimage
0 Answers
Your Answer