diff options
author | Sam Lantinga <slouken@libsdl.org> | 2017-08-14 05:51:44 -0700 |
---|---|---|
committer | Sam Lantinga <slouken@libsdl.org> | 2017-08-14 05:51:44 -0700 |
commit | df0ee407ab907ce150cc93b1cbb7c4dfcde8336b (patch) | |
tree | 2d914649189ddd6a7ccf558fc4b4aa4ec4599454 /test | |
parent | 99ec5024a3399f30e9ec742968038101c53d4cf6 (diff) |
Implemented more flexible blending modes for accelerated renderers
This fixes bug 2594 - Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA
blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
SDL_BLENDOPERATION_ADD,
SDL_BLENDFACTOR_ZERO,
SDL_BLENDFACTOR_ONE,
SDL_BLENDOPERATION_ADD);
This fixes bug 2828 - Subtractive Blending
blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
SDL_BLENDFACTOR_ONE,
SDL_BLENDOPERATION_SUBTRACT,
SDL_BLENDFACTOR_ZERO,
SDL_BLENDFACTOR_ONE,
SDL_BLENDOPERATION_SUBTRACT);
This goes partway to fixing bug 3684 - Add support for a pre-multiplied alpha blending mode
blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE,
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
SDL_BLENDOPERATION_ADD,
SDL_BLENDFACTOR_ONE,
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
SDL_BLENDOPERATION_ADD);
Diffstat (limited to 'test')
-rw-r--r-- | test/testsprite2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/testsprite2.c b/test/testsprite2.c index 6b924c3cb5..14258f74cd 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -99,7 +99,12 @@ LoadSprite(const char *file) SDL_FreeSurface(temp); return (-1); } - SDL_SetTextureBlendMode(sprites[i], blendMode); + if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError()); + SDL_FreeSurface(temp); + SDL_DestroyTexture(sprites[i]); + return (-1); + } } SDL_FreeSurface(temp); @@ -295,6 +300,9 @@ main(int argc, char *argv[]) } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { blendMode = SDL_BLENDMODE_MOD; consumed = 2; + } else if (SDL_strcasecmp(argv[i + 1], "sub") == 0) { + blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT, SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_SUBTRACT); + consumed = 2; } } } else if (SDL_strcasecmp(argv[i], "--iterations") == 0) { |