Sign in to follow this  
LilithAnn

[SDL] Trouble understanding alpha

Recommended Posts

I'm having major difficulty in understanding how to get some alpha performance out of SDL and turn to this group for help. The documentation for SDL is fine but some of it assumes prior understanding that isn't in my memory bank. Right now I'm experimenting but the jist of what I'm doing is, once everything is ostensibly set up is blitting a background surface that's set to all white onto the display surface and then directly setting several hundred individual pixels to the display surface. Initally I did this without alpha. Here are the essentials of what I'm (apparently erroneously) setting for using alpha.
SDL_Init (SDL_INIT_VIDEO);

screen = SDL_SetVideoMode (SW, SH, 32, SDL_SWSURFACE);

SDL_SetAlpha (screen, SDL_SRCALPHA, 255);

background = SDL_ConvertSurface (screen, screen->format, SDL_SWSURFACE);

// variance on the arguments for the alpha
// setting for screen and background are
// simply because I've tried all combinations
SDL_SetAlpha (background, SDL_SRCALPHA, 0);

// background has been filled with pure white
// but when it's blitted to the display surface
// it shows up black
SDL_BlitSurface (background, NULL, screen, NULL);
The last portion is part of a loop that also waits for input to end the test. There's also a call to draw my pixels to the display surface following the background to screen blit. Essentially I end up with a black screen with my pixels painted on. But since the previous set of pixels aren't erased I can only conjecture that the background to display surface blit isn't occurring. Even a pointer to a site with some overview would be helpful. Thanks, Lilith [Edited by - LilithAnn on October 9, 2006 4:53:07 PM]

Share this post


Link to post
Share on other sites
ACHHH! That was it. I was somehow reading that declaring alpha in flag invalidated anything in the per surface alpha. Bear with me. I'll get my head screwing in the other direction someday.

Thanks,

Lilith

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this