In my application I take snapshots of a QGLWidget's contents for two purposes:
- Not redraw the scene all the time when only an overlay changes, using a cached pixmap instead
- Lat the user take screenshots of the particular plots (3D scene)
The first thing I tried is grabFrameBuffer()
. It is natural to use this function as for the first application, what is currently visible in the widget is exactly what I want to cache.
PROBLEM: On some hardware (e.g. Intel integrade graphics, Mac OS X with GeForce graphics), the image obtained does not contain the current screen content, but the content before that. So if the scene would be drawn two times, on the screen you see the second drawing, in the image you see the first drawing (which should be the content of the backbuffer?).
The second thing I tried is renderToPixmap()
. This renders using paintGL()
, but not using paint()
. I have all my stuff in paint()
, as I use Qt's painting functionality and only a small piece of the code uses native GL (beginNativePainting()
, endNativePainting()
).
I also tried the regular QWidget's snapshot capability (QPixmap::fromWidget(), or what it is called), but there the GL framebuffer is black.
Any ideas on how to resolve the issue and get a reliable depiction of the currently drawn scene?