OpenGL screen capture?

I modified one of the Mesa demos for SDL, following the gears example
found at “http://www.libsdl.org/opengl/intro.html”. I’d like to take
screenshots when pressing a key. I first created a screen using
"SDL_SetVideoMode", then later in the code I tried to save the
screen using “SDL_SaveBMP” , but it’s crashing my application:
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

I’m new to graphic programming, so I’m quite sure I’m doing it wrong.
Since there’s a couple of functions in SDL that deals with video
and image buffers, there should be a way to save a 3D render in a
file.

Marc

“Marc Lavall?e” wrote

I’m new to graphic programming, so I’m quite sure I’m doing it wrong.
Since there’s a couple of functions in SDL that deals with video
and image buffers, there should be a way to save a 3D render in a
file.

someone just posted a great piece of code that takes an SDL
screenshot and works in both OpenGL and regular SDL mode.
it shouldn’t be more than a few weeks back, check the archives

Marc Lavall?e schrieb am 04 Sep 2000:

I modified one of the Mesa demos for SDL, following the gears example
found at “http://www.libsdl.org/opengl/intro.html”. I’d like to take
screenshots when pressing a key. I first created a screen using
"SDL_SetVideoMode", then later in the code I tried to save the
screen using “SDL_SaveBMP” , but it’s crashing my application:
Fatal signal: Segmentation Fault (SDL Parachute Deployed)

I’m new to graphic programming, so I’m quite sure I’m doing it wrong.
Since there’s a couple of functions in SDL that deals with video
and image buffers, there should be a way to save a 3D render in a
file.

You can’t access OpenGL pixels directly, you have to do a
glReadPixels, convert that into a surface, and then save it.

There was code posted on this list just 4 days ago. Check the archive.

  • Andreas–
    Check out my 3D lightcycle game: http://www.gltron.org
    More than 90’000 Downloads of the latest version (0.59)