I am using OpenGL and SDL, mostly to learn more of OpenGL. At some time it would be nice to take a screenshot. Pleasant was my surprise that this is not difficult to do. The code shown below is all you need. The
Listing 1:
_width
and _height
is your screen size in pixels. Listing 1:
There is a small caveat. The 'y' axis is swapped when you move from SDL to OpenGL. So you have to flip the SDL image vertically. The function in the code below does exactly that.
Listing 2:
No comments:
Post a Comment