I am trying to take screenshots of my OpenGL program on Linux. Gimp
failed, I guess it didn’t handle overlay or something. I quickly wrote
code
printf( "Saving screenshot… " ); fflush( stdout );
SDL_LockSurface( surf );
SDL_SaveBMP( surf, “screenshot.bmp” );
SDL_UnlockSurface( surf );
printf( “Done!\n” );
Where surf is my SDL OpenGL surface. Now, this thing simply hangs, and
when I press CTRL-C, it segfaults. Is SDL_SaveBMP() supposed to work on
OpenGL surfaces?
This won’t work at all. Try this, or something close (untested):
shot = SDL_CreateRGBSurface (SDL_SWSURFACE, surf->w, surf->h, 24,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
0x00FF0000, 0x0000FF00, 0x000000FF, 0);
#else
0x000000FF, 0x0000FF00, 0x00FF0000, 0);
#endif
glReadPixels (0, 0, surf->w, surf->h, GL_BGR, GL_UNSIGNED_BYTE,
shot->pixels);
SDL_SaveBMP (“screenshot.bmp”);
SDL_FreeSurface (shot);
SDL_Surface’s work with Uint32’s, not Uint8’s. This is frustrating
because byte order matters (I was just reminded of this myself…)
Use BGR, not RGB! This works around a bug with some broken drivers which
can only return BGR, regardless of what you ask for.
If not, how should I work around this? Can I create a software surface
of the same mode into which I could use glReadPixels(), so I could
finally use SDL_SaveBMP() on that surface?
Yes, similar to the above.On Sat, Apr 27, 2002 at 12:22:46AM +0300, Timo K Suoranta wrote:
–
Joseph Carter Not many fishes
Flinny: black crontab magic kinda stuff
Joy: does that mean people get to dance naked around bonfires
chanting strange things and waving their arms about in a silly
manner?
knghtbrd: what do you think people do at novare?
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020426/3a591d7c/attachment.pgp