SDL2::blendmode - SDL2 BlendMode Enumerations and Declarations
use SDL2 qw[:blendMode];
SDL2::blendmode
These may be imported by name or with the :blendMode tag.
:blendMode
SDL_ComposeCustomBlendMode( ... )
Compose a custom blend mode for renderers.
A blend mode controls how the pixels from a drawing operation (source) get combined with the pixels from the render target (destination). First, the components of the source and destination pixels get multiplied with their blend factors. Then, the blend operation takes the two products and calculates the result that will get stored in the render target.
Expressed in pseudocode, it would look like this:
$dstRGB = colorOperation( $srcRGB * $srcColorFactor, $dstRGB * $dstColorFactor ); $dstA = alphaOperation( $srcA * $srcAlphaFactor, $dstA * $dstAlphaFactor );
Where the functions colorOperation( $src, $dst) and alphaOperation( $src, $dst ) can return one of the following:
colorOperation( $src, $dst)
alphaOperation( $src, $dst )
$src + $dst
$src - $dst
$dst - $src
min($src, $dst)
max($src, $dst)
The red, green, and blue components are always multiplied with the first, second, and third components of the SDL_BlendFactor, respectively. The fourth component is not used.
SDL_BlendFactor
The alpha component is always multiplied with the fourth component of the SDL_BlendFactor. The other components are not used in the alpha calculation.
Support for these blend modes varies for each renderer. To check if a specific SDL_BlendMode is supported, create a renderer and pass it to either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will return with an error if the blend mode is not supported.
SDL_BlendMode
SDL_SetRenderDrawBlendMode
SDL_SetTextureBlendMode
This list describes the support of custom blend modes for each renderer in SDL 2.0.6. All renderers support the four blend modes listed in the SDL_BlendMode enumeration.
SDL_BLENDOPERATION_ADD
SDL_BLENDOPERATION_MINIMUM
SDL_BLENDOPERATION_MAXIMUM
SDL_BLENDOPERATION_SUBTRACT
SDL_BLENDOPERATION_REV_SUBTRACT
Some renderers do not provide an alpha component for the default render target. The SDL_BLENDFACTOR_DST_ALPHA and SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA factors do not have an effect in this case.
SDL_BLENDFACTOR_DST_ALPHA
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA
Expected parameters include:
srcColorFactor
dstColorFactor
colorOperation
srcAlphaFactor
dstAlphaFactor
alphaOperation
SDL_BlendOperation
Returns an SDL_BlendMode that represents the chosen factors and operations.
These may be imported by name.
The blend mode used in SDL_RenderCopy( ) and drawing operations. These may be imported by name or with the :blendMode tag.
SDL_RenderCopy( )
SDL_BLENDMODE_NONE
dstRGBA = srcRGBA
SDL_BLENDMODE_BLEND
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) dstA = srcA + (dstA * (1-srcA))
SDL_BLENDMODE_ADD
dstRGB = (srcRGB * srcA) + dstRGB dstA = dstA
SDL_BLENDMODE_MOD
dstRGB = srcRGB * dstRGB dstA = dstA
SDL_BLENDMODE_MUL
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) dstA = (srcA * dstA) + (dstA * (1-srcA))
SDL_BLENDMODE_INVALID
Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode( ... ).
The blend operation used when combining source and destination pixel components. These may be imported with the :blendOperation tag.
:blendOperation
dst + src
dst - src
src - dst
min(dst, src)
max(dst, src)
The normalized factor used to multiply pixel components. These may be imported with the :blendfactor tag.
:blendfactor
SDL_BLENDFACTOR_ZERO
0, 0, 0, 0
SDL_BLENDFACTOR_ONE
1, 1, 1, 1
SDL_BLENDFACTOR_SRC_COLOR
srcR, srcG, srcB, srcA
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR
1-srcR, 1-srcG, 1-srcB, 1-srcA
SDL_BLENDFACTOR_SRC_ALPHA
srcA, srcA, srcA, srcA
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
1-srcA, 1-srcA, 1-srcA, 1-srcA
SDL_BLENDFACTOR_DST_COLOR
dstR, dstG, dstB, dstA
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR
1-dstR, 1-dstG, 1-dstB, 1-dstA
dstA, dstA, dstA, dstA
1-dstA, 1-dstA, 1-dstA, 1-dstA
Copyright (C) Sanko Robinson.
This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.
Sanko Robinson <sanko@cpan.org>
To install SDL2::FFI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL2::FFI
CPAN shell
perl -MCPAN -e shell install SDL2::FFI
For more information on module installation, please visit the detailed CPAN module installation guide.