The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Texture fading animation
luca00555


Joined: 04 Jan 2015
Posts: 33
Location: The Netherlands
I'm trying to create an animation for my gui and I have no idea where to start:
Imagine a square 40x40, for every pixels it scrolls up, all rows of pixels in the square above the original Y position lose 10% opacity.
So, when the square scrolls up 1 pixel, the first row has 90% opacity.
When the square scrolls up another pixel, the first row has 80% opacity, and the second row has 90% opacity etc.. etc..
How would I do that (possibly without a massive performance loss)? I prefer textures over surfaces.

Thanks in advance Smile
luca00555


Joined: 04 Jan 2015
Posts: 33
Location: The Netherlands
Here is the real deal I'll be working with:
MrTAToad


Joined: 13 Feb 2014
Posts: 205
Location: Chichester, England
I believe you would need to convert to a surface (or have a surface as well as a texture) in order to manipulate the data (texture data is write-only) - this would mean the standard SDL pixel reading system can be used : Read in a pixel as usual; convert to RGBA; subtract the appropriate alpha value and then write back.

You would probably need to destroy and re-create the texture on each change, but that should be okay.
Alex


Joined: 19 Sep 2014
Posts: 35
I not sure can it help you, but I suggest to create vertical alpha gradient (another image with only alpha values and zeros in other channels) and combine this two images. Try to test it may be you get acceptable result.
luca00555


Joined: 04 Jan 2015
Posts: 33
Location: The Netherlands
Thanks, I'll try both and see what I can make of it.