In my application, I take QGLWidget snapshots for two purposes:
- Do not redraw the scene all the time when only the overlay changes, using the cached pixmap instead
- Allows the user to take screenshots of individual scenes (3D scene).
The first thing I tried is grabFrameBuffer(). It’s natural to use this function as for the first application, what is currently visible in widgets is exactly what I want to cache.
PROBLEM: . On some hardware (for example, Intel-compatible Mac OS X graphics with GeForce graphics), the resulting image does not contain the current screen content, but the content before that. So, if the scene is drawn twice, on the screen you will see the second drawing, in the image you will see the first drawing (which should be the contents of the back buffer?).
The second thing I tried is renderToPixmap(). This means use paintGL(), but not use paint(). I have all my stuff in paint(), since I use the Qt coloring functions, and only a small part of the code uses its own GL ( beginNativePainting(), endNativePainting()).
I also tried the regular QWidget snapshot feature (QPixmap :: fromWidget () or whatever it is called), but the GL framebuffer is black there.
Any ideas on how to solve the problem and get a reliable image of the current scene?
ypnos source
share