I tried to use SDL_SaveBMP() in combination with
what was returned from the call to
SDL_SetVideoMode(), but receive segmentation
faults. I use SDL in combination with OpenGL,
otherwise painlessly. Like this:
SDL_Surface *screen = SDL_SetVideoMode(…);
// here game&rendering works fine… up until
SDL_LockSurface(screen);
SDL_SaveBMP(screen, “screendump.bmp”); // crash
SDL_UnlockSurface(screen);
The SaveBMP call fails.
Of course, I could code something using OpenGL’s
raster copy functions, but I was just wondering if
this is a known problem and has any easy fix. And
I am a little lazy.
Look at RageDisplay::SaveScreenshot. (This function isn’t endian-safe.)On Thu, Apr 24, 2003 at 01:30:07AM +0200, Olof Bjarnason wrote:
I tried to use SDL_SaveBMP() in combination with
what was returned from the call to
SDL_SetVideoMode(), but receive segmentation
faults. I use SDL in combination with OpenGL,
otherwise painlessly. Like this:
SDL_Surface *screen = SDL_SetVideoMode(…);
// here game&rendering works fine… up until
SDL_LockSurface(screen);
SDL_SaveBMP(screen, “screendump.bmp”); // crash
SDL_UnlockSurface(screen);
The SaveBMP call fails.
Of course, I could code something using OpenGL’s
raster copy functions, but I was just wondering if
this is a known problem and has any easy fix. And
I am a little lazy.
hi,
i am not familiar with opengl surfaces but do you
really need to lock the surface before calling
SDL_SaveBMP at least the documentation says nothing
about that. Maybe you should try SDL_SaveBMP without
SDL_LockSurface ?
No, that won’t work. You don’t get a real screen surface when using
OpenGL. You can’t mix OpenGL with SDL 2D rendering calls either, so
it makes sense. The technical motivation for leaving it out is
probably that SDL would have to emulate it using OpenGL pixel calls,
which means very expensive locking and unlocking. (Both would require
a full screen VRAM<->system memory blit.)
So, if you’re using OpenGL, use it for this too. SDL is really meant
to wrap platform specific stuff, and there’s no need to duplicate
features of other portable APIs.
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Friday 25 April 2003 13.56, Marc Essinger wrote:
hi,
i am not familiar with opengl surfaces but do you
really need to lock the surface before calling
SDL_SaveBMP at least the documentation says nothing
about that. Maybe you should try SDL_SaveBMP without
SDL_LockSurface ?
hi,
i am not familiar with opengl surfaces but do you
really need to lock the surface before calling
SDL_SaveBMP at least the documentation says nothing
about that. Maybe you should try SDL_SaveBMP without
SDL_LockSurface ?
No, that won’t work. You don’t get a real screen surface when using
OpenGL. You can’t mix OpenGL with SDL 2D rendering calls either, so
it makes sense. The technical motivation for leaving it out is
probably that SDL would have to emulate it using OpenGL pixel calls,
which means very expensive locking and unlocking. (Both would require
a full screen VRAM<->system memory blit.)
So, if you’re using OpenGL, use it for this too. SDL is really meant
to wrap platform specific stuff, and there’s no need to duplicate
features of other portable APIs.
I think it’s worth mentioning that you can still use SDL Surface calls
and methods, just not mix them with the display. I’m writing an OpenGL
app using SDL and I’ve found it’s very useful to manipulate textures as
SDL Surfaces, and just create a method to convert them to OpenGL
textures. It also lets you use stuff like SDL_Image for loading
resources.
I’m sure you already know this, but for anyone that didn’t, “Can’t mix
OpenGL and SDL 2D calls” implies that all of the 2D functionality of SDL
is unavailable.On Fri, 2003-04-25 at 09:51, David Olofson wrote:
On Friday 25 April 2003 13.56, Marc Essinger wrote:
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —
From: david@olofson.net (David Olofson)
To:
Sent: Friday, April 25, 2003 6:51 AM
Subject: Re: [SDL] Screen dump using SDL+OGL
On Friday 25 April 2003 13.56, Marc Essinger wrote:
hi,
i am not familiar with opengl surfaces but do you
really need to lock the surface before calling
SDL_SaveBMP at least the documentation says nothing
about that. Maybe you should try SDL_SaveBMP without
SDL_LockSurface ?
No, that won’t work. You don’t get a real screen surface when using
OpenGL. You can’t mix OpenGL with SDL 2D rendering calls either, so
it makes sense. The technical motivation for leaving it out is
probably that SDL would have to emulate it using OpenGL pixel calls,
which means very expensive locking and unlocking. (Both would require
a full screen VRAM<->system memory blit.)
So, if you’re using OpenGL, use it for this too. SDL is really meant
to wrap platform specific stuff, and there’s no need to duplicate
features of other portable APIs.
//David Olofson - Programmer, Composer, Open Source Advocate
.- The Return of Audiality! --------------------------------.
| Free/Open Source Audio Engine for use in Games or Studio. |
| RT and off-line synth. Scripting. Sample accurate timing. |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —