Jump to content
  • Advertisement
Sign in to follow this  
Dark_Oppressor

OpenGL Alpha blending in SDL

This topic is 3066 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 little game using SDL + OpenGL. In addition to the OpenGL hardware renderer, I have started to implement a software renderer using SDL. I've got it mostly working, but opacity is proving problematic.

In OpenGL, I can simply set the opacity of each texture before rendering it. Simple.

In SDL, there appears to be no way to do anything like this. My actual images are currently 32-bit png's, and I am using their alpha channels instead of color keying. So, if I want a sprite to be somewhat transparent, I could just change the opacity of the actual image file and that would solve it. However, I also want to be able to change the opacity of a sprite during runtime, to make things fade in/out, etc.

I also wanted to be able to stick rectangles on the screen whenever I want, with whatever color and opacity I need. I've found tonight that SDL_gfx does this perfectly, and so I've got that working in SDL. I'm still stuck on doing something similar with surfaces. Basically, I need the equivalent of the glColor functions. Is there anything like this that I'm missing?

Share this post


Link to post
Share on other sites
Advertisement
Take a look here:
http://www.gamedev.net/reference/programming/features/mmxblend/page2.asp

Alpha blending is pretty easy to implement and if you're doing it for a picture, it's easy to take advantage of SSE and do it for multiple pixels at once.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!