Reputation: 757
I am working on an opengl based simulation application, in which I need to make multiple screenshots in a second. I have tried 2 ways of doing it in my application.
1) use glreadpixels
2) use x11 based screenshot. ex: ffmpeg -f x11grab -s 1024x768 -i :0.0 output.png
I found that second solution is about 3 times faster than first one. I have expected the first solution to be faster. But in practice it is slower. I am curious why glreadpixels is slower?
Upvotes: 0
Views: 142
Reputation: 43369
glReadPixels (...)
is a synchronous round-trip operation (when it is not used with a Pixel Buffer Object). You send it to GL, it has to finish all of the commands it has buffered up to that point and then it returns the result of that operation.
On the other hand, if you use a method defined by a window system to grab the contents of a window, the window system is free to implement the operation a number of different ways. Often you will get a copy of the last thing the window system actually presented, which may be 1 or more frames older than what you would get if you called glReadPixels (...)
and waited for GL to finish drawing.
Upvotes: 1