We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2538 - SDL_SetTextureAlphaMod does not work with SDL_FlipMode or rotation in the software renderer
Summary: SDL_SetTextureAlphaMod does not work with SDL_FlipMode or rotation in the sof...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.3
Hardware: x86_64 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-11 20:04 UTC by Adam M.
Modified: 2015-06-20 08:22 UTC (History)
0 users

See Also:


Attachments
proposed patch (v1) (2.16 KB, patch)
2015-06-20 01:33 UTC, Adam M.
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam M. 2014-05-11 20:04:35 UTC
When setting a texture alpha mod other than 255 and also specifying a flip mode in the software renderer, the rendering fails. When the texture has an alpha channel, it becomes invisible when flipped. When the texture does not have an alpha channel, it is flipped but the colors are wrong: the alpha mod makes the texture darker rather than more translucent.

0) Initialize a software renderer.
1) Load 16-bit 565 or 32-bit texture.
2) Set texture blend mode to BLEND.
3) Set texture alpha mod to 150.
4) Draw the texture flipped horizontally and/or vertically.
Comment 1 Adam M. 2014-05-11 20:08:00 UTC
It also doesn't work when the texture is rotated (but not flipped), with the same symptoms.
Comment 2 Adam M. 2015-06-20 01:33:19 UTC
Created attachment 2192 [details]
proposed patch (v1)

I've proposed a patch to fix this problem. You may want to apply the patch for bug #1550 first. (Bug #1550 may also break this scenario.)
Comment 3 Sam Lantinga 2015-06-20 06:23:17 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/c2ba8ab27c1a
Comment 4 Adam M. 2015-06-20 08:22:38 UTC
I don't like duplicating the code to copy color key, alpha mod, color mod, and blend mode between surfaces. It seems like there should be a helper function to do that kind of thing, in case more blending options are added in the future. Maybe it should copy the palette too, if the places that would call the helper also copy the palette.

I already fixed two pieces of code that assumed the only blending option was the color key. There may be more code that makes the same assumption. But that seemed like I'd have to add a new file to the code base (SDL_surface_c.h), and I'm not sure what all is involved in that -- possibly updating all the different project and make files -- so I didn't do it. But it seems like a good thing to do.