Reputation: 31
I am rendering images with flickering objects (usually 30Hz) using double buffering. For screenshots, I would like to blend together the current and the previous buffer, without having to store the previous buffer permanently.
How would I access SDL2's current front and back buffer and blend them into one buffer?
Upvotes: 3
Views: 666
Reputation: 13269
From the SDL_RenderPresent
documentation:
The backbuffer should be considered invalidated after each present; do not assume that previous contents will exist between frames.
The reason is probably that every backend does things differently, and so the SDL cannot guarantee anything about what a buffer contains after it gets presented (without incurring an unnecessary performance penalty).
So you have to store the previous buffer yourself. That said, you probably don't have to copy the buffer everytime, just do it for the frame you want a screenshot of.
Upvotes: 0