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 2810 - Proposal: add SDL_BLENDMODE_ALPHA which affects only alpha-channel
Summary: Proposal: add SDL_BLENDMODE_ALPHA which affects only alpha-channel
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.3
Hardware: x86 Other
: P2 enhancement
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-08 10:23 UTC by Ivan Epifanov
Modified: 2014-12-12 09:07 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Epifanov 2014-12-08 10:23:45 UTC
Something like this (tested in opengl renderer)
        case SDL_BLENDMODE_ALPHA:
            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
            data->glEnable(GL_BLEND);
            data->glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_ONE, GL_ZERO);
            break;

This allows applying alpha masks to texture using alpha-channel from other texture, like this:
                SDL_SetRenderTarget(gRenderer, texBuf);

                SDL_SetTextureBlendMode(baseTexture,SDL_BLENDMODE_NONE);
                SDL_SetTextureBlendMode(maskTexture,SDL_BLENDMODE_ALPHA);
                SDL_RenderCopy(gRenderer,baseTexture, NULL, NULL);
                SDL_RenderCopy(gRenderer,eggTexture, NULL, NULL);

After that we'll have baseTexture with alpha channel from maskTexture in texBuff.

Or maybe there's a better way to do this?
Comment 1 Ivan Epifanov 2014-12-12 09:07:09 UTC
Nevermind. It's impossible to do without glBlendFuncSeparate, and we found another solution.