Sdl_Swsurface Alpha Problem


PokeParadox

Founder of Pirate Games - Penjin Coder
Staff member
Joined
Dec 8, 2005
Messages
6,603
Age
40
Location
UK
Website
pokeparadox.itch.io
WEBSITE
https://github.com/pokeparadox
YOUTUBE
pokeparadox
Well hi GP32X collective,

I am having a blending problem in SDL. When I render a HW surface everything is fine, I can set the alpha of the surface and render it and it is transparent according to the alpha.
I try and do this for a SW surface and it is either there or not...

I need the SW support to support the gradual PerPixelAlpha of png but I also need to be able to fade the surface in general and rotate and scale...

Anyone got any suggestions in general as to what may be wrong... I can obviously post code samples but the code is the Image class from the Penjin repo

As usual, any help and suggestions is greatly appreciated!
 
SDL's alpha support is weird. When rendering a surface to another surface, alpha is not blended or combined the way you'd expect. It uses the alpha channel of the destination surface only. If you have a sprite with an alpha channel and draw it onto a surface that has an alpha channel too, SDL ignores the alpha channel of the sprite completely. What's worse is if the destination surface is 100% transparent, so is your sprite. I had to write a custom blitting routine in software to achieve the correct results, and it was pretty darned slow.
 
Back
Top