Surface allocation problems

I’m having some serious problems with surface allocations using SDL.
When I create surfaces “implicitly” by loading in BMP graphics,
everything’s fine. But when I try to create surfaces myself, using
AllocSurface() and then filling the surface with some pixels, one
of two things always happen as I try to blit the surface to the
screen: a) nothing is shown, or b) SDI segfaults.

This is really becoming annoying.

Attached is a tgz archive containing a small test program (roughly
one page of C) in source and binary (Linux, ELF, i386, X11). As far
as I understand from the SDL documentation, there is nothing wrong
with the program, yet it fails to work for allocated surfaces…

Any hints?

/Emil

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/octet-stream
Size: 4673 bytes
Desc:
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/19980413/3393af67/attachment.obj

I’m having some serious problems with surface allocations using SDL.

Two problems are at work here.
The first, the crash when allocating a hardware surface, is caused by
my not clearing the hardware flag when allocating a hardware surface.
This is fixed in 0.6d which will be released in a few minutes. :slight_smile:

The second, more subtle, is the fact that you are not setting the
colormap and/or are overrunning the palette. Both problems are warned
about in the fixed source/exe that I’m attaching.

Also, ALWAYS check to make sure SDL_Init() returns successfully. :slight_smile:
Otherwise you may be calling stub functions which point to NULL.

Another thing, when debugging an SDL program, keep in mind that
SIGINT and SIGTERM are mapped to an SDL_QUIT event, while SIGQUIT
is left alone. If you set a signal handler for either signal, your
handler will not be replaced.
This means that if you want to kill a runaway SDL process, kill it
with ^\ or signal 3 rather then ^C or signal 2 or 15.

Any hints?

Yep! :slight_smile:

See ya!
-Sam Lantinga (slouken at devolution.com)–
Author of Simple DirectMedia Layer -
http://www.devolution.com/~slouken/SDL/

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/octet-stream
Size: 18530 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/19980413/92767269/attachment.obj