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
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