Jump to content
  • Advertisement
Sign in to follow this  

[SDL] Trouble understanding alpha

This topic is 4365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.

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
Assuming that 'screen' defaults to black, the reason you're not seeing 'background' is because an alpha value of 0 means it's completely transparent. Try turning your values around.

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.



Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!