Create a surface and fill it with a white color

Hello fellows!
I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

I’ve read the manual for about two hours by now. Have anybody a clue how I’m
supose to do? Sorry for my English, I’m only 14.

/ Daniel L?nnstr?m

You’re creating a 8-bit, paletted texture but you’re not
initializing the palette… maybe the white (255,255,255)
color just doesn’t exist?

I don’t know if SDL gives you a default palette (I use mostly
truecolor surfaces) so this may not be the problem…

Ing. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy> ----- Original Message -----

From: Daniel L?nnstr?m [mailto:danne_89@home.se]
Sent: Lunes, 09 de Febrero de 2004 03:54 p.m.
To: sdl at libsdl.org
Subject: [SDL] Create a surface and fill it with a white color

Hello fellows!
I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0); Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255); SDL_FillRect(mBakgrund, 0, color);

I’ve read the manual for about two hours by now. Have anybody a clue how I’m
supose to do? Sorry for my English, I’m only 14.

/ Daniel L?nnstr?m


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

Hello fellows!
I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

Is mBackgrund supposed to be the screen? The screen is a special sort of
surface which you create with SDL_SetVideoMode, not with a normal create
surface function.

JamesOn Mon, 09 Feb 2004 19:53:42 +0100, Daniel L?nnstr?m wrote:

No, mBackgrund is just a ordinary surface.On Mon, Feb 09, 2004 at 07:30:33PM +0000, James Gregory wrote:

On Mon, 09 Feb 2004 19:53:42 +0100, Daniel L?nnstr?m wrote:

Hello fellows!
I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

Is mBackgrund supposed to be the screen? The screen is a special sort of
surface which you create with SDL_SetVideoMode, not with a normal create
surface function.

James

Hello fellows!
I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

Is mBackgrund supposed to be the screen? The screen is a special sort of
surface which you create with SDL_SetVideoMode, not with a normal create
surface function.

James

No, mBackgrund is just a ordinary surface.

In what way does it not work?

After doing the above, do you then blit mBackgrund to the screen?

JamesOn Tue, 10 Feb 2004 17:48:26 +0100, Daniel L?nnstr?m wrote:

On Mon, Feb 09, 2004 at 07:30:33PM +0000, James Gregory wrote:

On Mon, 09 Feb 2004 19:53:42 +0100, Daniel L?nnstr?m wrote:

Hello fellows!
I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

Is mBackgrund supposed to be the screen? The screen is a special sort of
surface which you create with SDL_SetVideoMode, not with a normal create
surface function.

James

No, mBackgrund is just a ordinary surface.

In what way does it not work?

After doing the above, do you then blit mBackgrund to the screen?

James
Yep I do, but I got a black color.On Tue, Feb 10, 2004 at 06:10:57PM +0000, James Gregory wrote:
On Tue, 10 Feb 2004 17:48:26 +0100, Daniel L?nnstr?m wrote:

On Mon, Feb 09, 2004 at 07:30:33PM +0000, James Gregory wrote:

On Mon, 09 Feb 2004 19:53:42 +0100, Daniel L?nnstr?m wrote:

I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

I’m not completely sure, but shouldn’t the mask arguments (the last four
zeros) of the SDL_CreateRGBSurface() call be something else than zero?
At least when you’re dealing with 16/32 bit surfaces, they must not be
zeros.

Since you’re creating a HW surface, I suppose you’d want to use the mask
values from the screen surface…?
Like this:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask,
screen->format->Amask);–
Mika Halttunen
@Mika_Halttunen

Did you see my post about initializing the palette?

Ing. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy> ----- Original Message -----

From: Daniel L?nnstr?m [mailto:danne_89@home.se]
Sent: Mi?rcoles, 11 de Febrero de 2004 01:34 p.m.
To: sdl at libsdl.org
Subject: Re: [SDL] Re: [SDL]: Create a surface and fill it with a white color

On Tue, Feb 10, 2004 at 06:10:57PM +0000, James Gregory wrote:

On Tue, 10 Feb 2004 17:48:26 +0100, Daniel L?nnstr?m wrote:

On Mon, Feb 09, 2004 at 07:30:33PM +0000, James Gregory wrote:

On Mon, 09 Feb 2004 19:53:42 +0100, Daniel L?nnstr?m wrote:

Hello fellows!
I want to create and fill a surface with a white color. A use
this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0,
0, 0, 0); Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255
,255); SDL_FillRect(mBakgrund, 0, color);

Is mBackgrund supposed to be the screen? The screen is a special
sort of surface which you create with SDL_SetVideoMode, not with a
normal create surface function.

James

No, mBackgrund is just a ordinary surface.

In what way does it not work?

After doing the above, do you then blit mBackgrund to the screen?

James

Yep I do, but I got a black color.


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

Did you see my post about initializing the palette?

That does sound quite likely if it always comes out black…

JamesOn Wed, 11 Feb 2004 13:07:19 -0300, Gabriel Gambetta wrote:

I want to create and fill a surface with a white color. A use this code:

mBackgrund = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0);
Uint32 color = SDL_MapRGB(mBakgrund->format, 255, 255 ,255);
SDL_FillRect(mBakgrund, 0, color);

I’m not completely sure, but shouldn’t the mask arguments (the last four
zeros) of the SDL_CreateRGBSurface() call be something else than zero?
At least when you’re dealing with 16/32 bit surfaces, they must not be

I use zeros, and it seems to work for me. Doesn’t using zeros mean “block
any pure black from getting through”, which basically means do nothing? I
may well be wrong, though.

JamesOn Wed, 11 Feb 2004 18:17:55 +0200, Mika Halttunen wrote: