[SDL] preparing a surface

Martin Donlon akawaka at csn.ul.ie
Sun Apr 23 10:24:23 PDT 2000


On Sat, 22 Apr 2000, Sam Hart wrote:

> I was just wondering how I can go about initiallizing a surface with
> certain set properties (such as res., bpp, default fill color). The
> surface is not to be init'd in a window or loaded from a file.
> 
> I want to use this to create a background (actually, layers or bkgs) for
> scrolling.
> 
> I thought I could use SDL_CreateRGBSurface(), but, if so,  obviously I'm
> using it wrong. If this is the function you use, how do you use
> it? (Specifically, what are you telling it by passing the RGB and A mask
> values... I thought this was a default fill color...)
To create a surface with the same properties as the screen do:

SDL_Surface *new;

new=SDL_CreateRGBSurface(0, width, height, screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask,
screen->format->Amask);

or messier

SDL_Surface *temp, *new;
temp=SDL_CreateRGBSurface(0, width, height, 32, 0, 0, 0, 0);
new=SDL_ConvertSurface(temp, screen->format, 0);
SDL_FreeSurface(temp);


Long live the confused,
                  Akawaka.
--
Bother! said Pooh, as he deleted C:\WINDOWS.




More information about the SDL mailing list