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

Adding GPU_BLEND_MULTIPLY_COLOR #136

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Nuk510
Copy link
Contributor

@Nuk510 Nuk510 commented May 15, 2018

This pull request adds GPU_BLEND_MULTIPLY_COLOR, which is functionally identical to SDL_BLENDMODE_MOD (see https://wiki.libsdl.org/SDL_BlendMode).

SDL_BLENDMODE_MOD
    color modulate
    dstRGB = srcRGB * dstRGB
    dstA = dstA

I also omitted value initialization from the GPU_BlendPresetEnum enumerated list to make for quicker editing in the future. This is because

typedef enum {
    A,
    B,
    C
} ABCenum;

is treated identically to

typedef enum {
    A = 0,
    B = 1,
    C = 2
} ABCenum;

by compilers. The same code is generated, but it's now easier to add, say, A2 between A and B without having to manually go through and say B=2 and C=3 now.

I hope that makes sense and that this helps. Keep up the great work on this API!

This is functionally identical to `SDL_BLENDMODE_MOD` (https://wiki.libsdl.org/SDL_BlendMode). Multiplies colors, but leaves alpha alone.
```
SDL_BLENDMODE_MOD
	color modulate
	dstRGB = srcRGB * dstRGB
	dstA = dstA
```
Added GPU_BLEND_MULTIPLY_COLOR, which is functionally identical to SDL_BLENDMODE_MOD. Also omitted GPU_BlendPresetEnum initialization to make code cleaner and easier to edit, because compilers will default each enumerated value in the order defined as 0, 1, 2, etc just as before.
@grimfang4
Copy link
Owner

I'll take another look at this. The feature is a good one.

The value initialization is intentional in order to preserve value compatibility. If a new value is added, it should not change the values of the ones that already exist unless a breaking change is acceptable.

@grimfang4 grimfang4 self-assigned this Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants