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

Summary: Proposal: add SDL_BLENDMODE_ALPHA which affects only alpha-channel
Product: SDL Reporter: Ivan Epifanov <isage.dna>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2 CC: i.gnatenko.brain, mail
Version: 2.0.3   
Hardware: x86   
OS: Other   

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.