Skip to main content
gamedev.net
🔒 Locked

SDL Transparency help needed

Started by MetroidHunter 1 reply 600+ views
Original Post
MetroidHunter
MetroidHunter
I just started using SDL today. I am able to make an image move on the screen, but I can''t figure out how to set the transparency using this statement: SDL_SetColorKey(surface, SDL_SRCCOLORKEY, SDL_MapRGB(surface->format, r, g, b)); I want to make it so green 255 is transparent, but I can''t figure out what to do with the surface->format statement. Can anyone help me out? Thanks in advance
-Thork-
-Thork-
Cross-posting is baaaaaad.....
baumep
baumep
Try SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGB(surface->format, 0, 255, 0));
.
SDL_MapRGB takes the surface->format parameter because it needs this information to know what kind of image the surface is. It may be an eight bit paletted image or a 32 bit true color surface. Each format has to be handled in a different way internally to achieve transparency.
baumep

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.