SFML
Simple and Fast Multimedia Library
Loading...
Searching...
No Matches
BlendMode.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#pragma once
26
28// Headers
31
32
33namespace sf
34{
35
41{
48 enum class Factor
49 {
51 One,
52 SrcColor,
53 OneMinusSrcColor,
54 DstColor,
55 OneMinusDstColor,
56 SrcAlpha,
57 OneMinusSrcAlpha,
58 DstAlpha,
59 OneMinusDstAlpha
60 };
61
68 enum class Equation
69 {
70 Add,
71 Subtract,
72 ReverseSubtract,
73 Min,
74 Max
75 };
76
83 BlendMode() = default;
84
96 BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Equation::Add);
97
109 BlendMode(Factor colorSourceFactor,
110 Factor colorDestinationFactor,
111 Equation colorBlendEquation,
112 Factor alphaSourceFactor,
113 Factor alphaDestinationFactor,
114 Equation alphaBlendEquation);
115
117 // Member Data
125};
126
137[[nodiscard]] SFML_GRAPHICS_API bool operator==(const BlendMode& left, const BlendMode& right);
138
149[[nodiscard]] SFML_GRAPHICS_API bool operator!=(const BlendMode& left, const BlendMode& right);
150
152// Commonly used blending modes
154// NOLINTBEGIN(readability-identifier-naming)
161// NOLINTEND(readability-identifier-naming)
162
163} // namespace sf
164
165
#define SFML_GRAPHICS_API
Definition Export.hpp:42
Definition BlendMode.hpp:34
SFML_GRAPHICS_API const BlendMode BlendAdd
Add source to dest.
SFML_GRAPHICS_API const BlendMode BlendAlpha
Blend source and dest according to dest alpha.
SFML_GRAPHICS_API const BlendMode BlendNone
Overwrite dest with source.
@ Zero
If the stencil test passes, the value in the stencil buffer is set to zero.
Definition StencilMode.hpp:63
SFML_GRAPHICS_API const BlendMode BlendMin
Take minimum between source and dest.
SFML_GRAPHICS_API const BlendMode BlendMultiply
Multiply source and dest.
SFML_GRAPHICS_API const BlendMode BlendMax
Take maximum between source and dest.
SFML_GRAPHICS_API bool operator!=(const BlendMode &left, const BlendMode &right)
Overload of the != operator.
Factor colorSrcFactor
Source blending factor for the color channels.
Definition BlendMode.hpp:119
BlendMode()=default
Default constructor.
Equation alphaEquation
Blending equation for the alpha channel.
Definition BlendMode.hpp:124
BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor, Equation colorBlendEquation, Factor alphaSourceFactor, Factor alphaDestinationFactor, Equation alphaBlendEquation)
Construct the blend mode given the factors and equation.
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation=Equation::Add)
Construct the blend mode given the factors and equation.
Equation
Enumeration of the blending equations.
Definition BlendMode.hpp:69
@ Add
Pixel = Src * SrcFactor + Dst * DstFactor.
Definition BlendMode.hpp:70
Factor alphaSrcFactor
Source blending factor for the alpha channel.
Definition BlendMode.hpp:122
Factor alphaDstFactor
Destination blending factor for the alpha channel.
Definition BlendMode.hpp:123
Factor colorDstFactor
Destination blending factor for the color channels.
Definition BlendMode.hpp:120
SFML_GRAPHICS_API bool operator==(const BlendMode &left, const BlendMode &right)
Overload of the == operator.
Equation colorEquation
Blending equation for the color channels.
Definition BlendMode.hpp:121
Factor
Enumeration of the blending factors.
Definition BlendMode.hpp:49
@ One
(1, 1, 1, 1)
Definition BlendMode.hpp:51
@ OneMinusSrcAlpha
(1, 1, 1, 1) - (src.a, src.a, src.a, src.a)
Definition BlendMode.hpp:57
@ SrcAlpha
(src.a, src.a, src.a, src.a)
Definition BlendMode.hpp:56