Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA #1525

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA #1525

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.3
Reported for operating system, platform: Other, x86_64

Comments on the original bug report:

On 2014-06-19 20:24:02 +0000, Trygve Vea wrote:

Created attachment 1693
Implements SDL_BLENDMODE_BLEND_DSTA on opengl, d3d, d3d11, and gles2 w/o shaders renderers.

Hello,

I want to propose a new blend mode (SDL_BLENDMODE_BLEND_DSTA), which is
based on SDL_BLENDMODE_BLEND, but without modifying the destination alpha.

The use case for this is when I am rendering to a texture containing an
irregular shape - and do not want to modify the alpha channel of the
destination target.

I need something like this for a project I'm doing, but I would prefer to
not maintain my own patchset if I can avoid it.

I've attached a patch, which I've tested on Linux with the OpenGL renderer

  • however, the patch does contain code that I THINK will work with d3d,
    d3d11, and gles2 without shaders as well - these are currently untested,
    but I left them in as the code looks pretty straight forward.

I looked briefly through SDLs website without finding any information of
how you deal with third party patches - but I would gladly make any
necessary modifications to help get this merged, if you would accept it.

Regards

Trygve Vea

On 2017-08-14 13:00:13 +0000, Sam Lantinga wrote:

This is implemented for accelerated renderers in this commit:
https://hg.libsdl.org/SDL/rev/180e8906dc3c

I think this is what you want:

    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);

On 2017-08-14 13:00:30 +0000, Sam Lantinga wrote:

Implemented!

On 2017-08-14 14:06:40 +0000, Sylvain wrote:

Just wondering: could this has introduced an issue within opengles2 renderer ?
I think I start to see pink colorkey with this commit. (and not when switching to opengles, or opengl).

On 2017-08-14 14:14:21 +0000, Sam Lantinga wrote:

It's possible, can you back out the commit and see if that fixes it?

On 2017-08-14 14:15:29 +0000, Sylvain wrote:

have tried yet, but this can be reproduced with

testspriteminimal.c

SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles2");

On 2017-08-14 14:21:04 +0000, Sylvain wrote:

indeed,

hg update -r 42b62c737891 is ok

hg update -r 180e8906dc3c is bad : wrong display when using opengles2

On 2017-08-14 14:50:39 +0000, Sam Lantinga wrote:

Interesting, I'm not seeing that here. OpenGLES renderer is fine with testspriteminimal and testsprite2. Could it be a different screen format that's causing problems?

On 2017-08-14 15:02:45 +0000, Sylvain wrote:

This is not OpenGLES 1 (which is fine) but OpenGLES2 !
For testspritemininal, I dont see pink, but white background (instead of transparent).

see screenshot

On 2017-08-14 15:03:09 +0000, Sylvain wrote:

Created attachment 2852
screenshot

On 2017-08-14 15:30:33 +0000, Sylvain wrote:

I haved tested with opengles1 on deskop (it fallback to opengl). But I tested it on android.

so on desktop :

  • opengl = ok
  • opengles2 = fail

on android :

  • opengles = ok
  • opengles2 = fail

On 2017-08-14 15:30:57 +0000, Sylvain wrote:

oops:
I haved not tested with opengles1 on deskop (it fallback to opengl). But I tested it on android.

On 2017-08-14 16:21:06 +0000, Sylvain wrote:

I think the issue is in GLES2_SetupCopy()

it may be :

GLES2_SetBlendMode(data, texture->blendMode);

and not

GLES2_SetBlendMode(data, renderer->blendMode);

On 2017-08-14 16:50:08 +0000, Sylvain wrote:

And also some warning when compiling application:

include/SDL2/SDL_blendmode.h:68:46: warning: commas at the end of enumerator lists are a C++11 extension [-Wc++11-extensions]
SDL_BLENDOPERATION_MAXIMUM = 0x5, /< max(dst, src) : supported by D3D11 */
^~
include/SDL2/SDL_blendmode.h:86:46: warning: commas at the end of enumerator lists are a C++11 extension [-Wc++11-extensions]
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA, /
< 1-dstA, 1-dstA, 1-dstA, 1-dstA */

On 2017-08-14 17:16:31 +0000, Sam Lantinga wrote:

Fixed, thanks!

@SDLBugzilla SDLBugzilla added the enhancement New feature or request label Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant