|
-
May 5th, 2008, 12:53 PM
#1
SDL: Blit to a non-visible surface
I am trying to write a method which returns an SDL_Surface*. The code I am using is:
Code:
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?
Code:
SDLApplication app;
SDLMenu menu = SDLMenu();
SDL_BlitSurface(menu.getSurface(), NULL, app.getScreen(), NULL);
SDL_Flip(app.getScreen());
SDL_Delay(10000);
return 0;
Thanks,
Gary
-
May 6th, 2008, 10:24 AM
#2
Re: SDL: Blit to a non-visible surface
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:
Code:
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);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|