Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


SDL Alpha Blending

This topic is 5550 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 working on a simple little game using SDL, now what I want to happen is when you complete a level, the background is set to be slightly transparent so that on a black background the image looks to be grayed out.. I''m guessing that this is done with Alpha blending somehow but I''ve never used it so I don''t really know how that would all work.. on the SDL site it shows a bunch of functions that deal with alpha blending but doesn''t really give an example on how to use them, so I was wondering if I was looking into the rigth technique and also if anyone can give a quick example on how I might go about doing this.. Please visit Turt99 Productions

Share this post

Link to post
Share on other sites
You'd want to do something like this:

/* This is the "You Win!" or whatever that you want to show
transparently over the game screen. (naturally, load it with a
bitmap or create the image) */
SDL_Surface *blended;
Uint8 amount=128; // Half transparent. 255 is opaque, 0 is full transparent.

You could also supply dest or source Rects for the blit call, it doesn't affect blending.

If you want to use the blended surface later, in a non-blended manner, just call SDL_SetAlpha with 0 for the second argument.

[edited by - TravisWells on May 6, 2003 11:37:36 PM]

Share this post

Link to post
Share on other sites

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