SDL_CreateRGBSurface in windowed mode

I’m fairly new too SDL so . . .

I have a problem (parachute deploys) when I do the following and I’m not
sure why.

I create the primary surface. Create an additianal surface using
SDL_CreateRGBSurface. Use SDL_FillRect on the additional surface.

This works fine when in Fullscreen mode, but in windowed mode it deploys
the parachute. I’m running under Win2000 with vc++. The following is the
code I am referring too. The parachute is deployed when I try to FillRect.

pSurface = SDL_SetVideoMode ( SCREENWIDTH , SCREENHEIGHT , SCREENBPP ,
SCREENFLAGS );
background = SDL_CreateRGBSurface( SDL_SWSURFACE, SCREENWIDTH,
SCREENHEIGHT, SCREENBPP, NULL, NULL, NULL, NULL );
SDL_FillRect ( background , NULL , TRANSPARENT_COLOR );

Kent Bolton wrote:

pSurface = SDL_SetVideoMode ( SCREENWIDTH , SCREENHEIGHT , SCREENBPP
, SCREENFLAGS );

Check the value of pSurface. If NULL, use SDL_GetError().

background = SDL_CreateRGBSurface( SDL_SWSURFACE, SCREENWIDTH,
SCREENHEIGHT, SCREENBPP, NULL, NULL, NULL, NULL );

Check the value of background. If NULL, If NULL, use SDL_GetError().

If these are both non-NULL, perhaps post a bit more of your
initialisation code?–
Kylotan
http://pages.eidosnet.co.uk/kylotan

I thought I would reply back so others can learn from my mistakes.

I figured out what the problem was. I had a macro called SCREENBPP defined
to be 0. I used this in my call to SDL_SetVideoMode(). This is fine since
I was also specifying SDL_ANYFORMAT for the surface type. So, SDL just
figured out what the best match would be.

The problem was that I was also using this macro in my call to
SDL_CreateRGBSurface(). In this function you cann’t specify SDL_ANYFORMAT.
So, it created a surface with bits per pixel being something other then a
legal value. So, when I tried to draw to the surface SDL deployed the
parachute. Hope this helps others to avoid this problem in the future.--------- Original message --------
From: kylotan@kylotan.eidosnet.co.uk (Kylotan)
To: “sdl at libsdl.org
Subject: Re: [SDL] SDL_CreateRGBSurface in windowed mode
Date: 02-12-03 06:32

Kent Bolton wrote:

pSurface = SDL_SetVideoMode ( SCREENWIDTH , SCREENHEIGHT , SCREENBPP
, SCREENFLAGS );

Check the value of pSurface. If NULL, use SDL_GetError().

background = SDL_CreateRGBSurface( SDL_SWSURFACE, SCREENWIDTH,
SCREENHEIGHT, SCREENBPP, NULL, NULL, NULL, NULL );

Check the value of background. If NULL, If NULL, use SDL_GetError().

If these are both non-NULL, perhaps post a bit more of your
initialisation code?


Kylotan
http://pages.eidosnet.co.uk/kylotan


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