Screen dump using SDL+OGL

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. :slight_smile:

/Olof

I avoid trying to use the OpenGL framebuffer as a surface, since I don’t
know how or if that works and don’t care to find out. :slight_smile: Check:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/stepmania/stepmania/src/RageDisplay.cpp?rev=1.125&content-type=text/vnd.viewcvs-markup

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. :slight_smile:


Glenn Maynard

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 ?

Ciao,
Marc__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Bis zu 100 MB Speicher bei http://premiummail.yahoo.de

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.nethttp://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.nethttp://www.reologica.se


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Jimmy <@Jimmy>
Jimmy’s World.org
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030425/744b19d6/attachment.pgp

do you guys know about this?

http://www.cevis.uni-bremen.de/~uwe/opengl/glReadPixels.html
void glReadPixels(GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLvoid *pixels)> ----- Original Message -----

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.nethttp://www.reologica.se


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I hope so; I provided code that uses this call …On Fri, Apr 25, 2003 at 10:26:03AM -0700, Atrix Wolfe wrote:

do you guys know about this?

http://www.cevis.uni-bremen.de/~uwe/opengl/glReadPixels.html
void glReadPixels(GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLvoid *pixels)


Glenn Maynard

nevermind then (:> ----- Original Message -----

From: g_sdl@zewt.org (Glenn Maynard)
To:
Sent: Friday, April 25, 2003 10:54 AM
Subject: Re: [SDL] Screen dump using SDL+OGL

On Fri, Apr 25, 2003 at 10:26:03AM -0700, Atrix Wolfe wrote:

do you guys know about this?

http://www.cevis.uni-bremen.de/~uwe/opengl/glReadPixels.html
void glReadPixels(GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
GLvoid *pixels)

I hope so; I provided code that uses this call …


Glenn Maynard


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl