sdl-gpu icon indicating copy to clipboard operation
sdl-gpu copied to clipboard

Adding GPU_BLEND_MULTIPLY_COLOR

Open Nuk510 opened this issue 7 years ago • 1 comments

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!

Nuk510 avatar May 15 '18 18:05 Nuk510

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 avatar Mar 25 '20 18:03 grimfang4