Click to See Complete Forum and Search --> : SDL: Blit to a non-visible surface


fatlardo
May 5th, 2008, 01:53 PM
I am trying to write a method which returns an SDL_Surface*. The code I am using is:

SDL_Surface* SDLMenu::getSurface() {
//Create and unlock surface
SDL_Surface* output = SDL_CreateRGBSurface(SDL_SWSURFACE, 100, 25, 32, 0, 0, 0, 0);
SDL_UnlockSurface(output);

SDL_FillRect(output, 0, SDL_MapRGB(output->format, 255, 0, 255));

SDL_LockSurface(output);

return output;
}

The problem I have is when I call this function, the output shown is a black screen. Can anyone tell me where I'm going wrong?

SDLApplication app;

SDLMenu menu = SDLMenu();
SDL_BlitSurface(menu.getSurface(), NULL, app.getScreen(), NULL);

SDL_Flip(app.getScreen());

SDL_Delay(10000);

return 0;

Thanks,
Gary

IllegalCharacter
May 6th, 2008, 11:24 AM
Since your masks are all zero, it filters out any colours you're trying to put. Hence why you have black ;)

Try putting this in: Uint32 rmask, gmask, bmask, amask;
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;

SDL_Surface * output = SDL_CreateRGBSurface(SDL_SWSURFACE, 100, 25, 32,
rmask, gmask, bmask, amask);