SFML 3.0.2
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-2025 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
30#include <SFML/Graphics/Export.hpp>
31
32
33 namespace sf
34{
35
40 struct SFML_GRAPHICS_API BlendMode
41{
48 enum class Factor
49 {
50 Zero,
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
119 Factor colorSrcFactor{BlendMode::Factor::SrcAlpha};
120 Factor colorDstFactor{BlendMode::Factor::OneMinusSrcAlpha};
121 Equation colorEquation{BlendMode::Equation::Add};
122 Factor alphaSrcFactor{BlendMode::Factor::One};
123 Factor alphaDstFactor{BlendMode::Factor::OneMinusSrcAlpha};
124 Equation alphaEquation{BlendMode::Equation::Add};
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)
155 SFML_GRAPHICS_API extern const BlendMode BlendAlpha;
156 SFML_GRAPHICS_API extern const BlendMode BlendAdd;
157 SFML_GRAPHICS_API extern const BlendMode BlendMultiply;
158 SFML_GRAPHICS_API extern const BlendMode BlendMin;
159 SFML_GRAPHICS_API extern const BlendMode BlendMax;
160 SFML_GRAPHICS_API extern const BlendMode BlendNone;
161// NOLINTEND(readability-identifier-naming)
162
163} // namespace sf
164
165
Export.hpp
SFML_GRAPHICS_API
#define SFML_GRAPHICS_API
Definition Graphics/Export.hpp:42
sf
Definition AudioResource.hpp:36
sf::BlendMin
const BlendMode BlendMin
Take minimum between source and dest.
sf::BlendAlpha
const BlendMode BlendAlpha
Blend source and dest according to dest alpha.
sf::BlendAdd
const BlendMode BlendAdd
Add source to dest.
sf::BlendMax
const BlendMode BlendMax
Take maximum between source and dest.
sf::BlendNone
const BlendMode BlendNone
Overwrite dest with source.
sf::BlendMultiply
const BlendMode BlendMultiply
Multiply source and dest.
sf::BlendMode::operator==
bool operator==(const BlendMode &left, const BlendMode &right)
Overload of the operator==
sf::BlendMode::colorSrcFactor
Factor colorSrcFactor
Source blending factor for the color channels.
Definition BlendMode.hpp:119
sf::BlendMode::BlendMode
BlendMode()=default
Default constructor.
sf::BlendMode::alphaEquation
Equation alphaEquation
Blending equation for the alpha channel.
Definition BlendMode.hpp:124
sf::BlendMode::BlendMode
BlendMode(Factor colorSourceFactor, Factor colorDestinationFactor, Equation colorBlendEquation, Factor alphaSourceFactor, Factor alphaDestinationFactor, Equation alphaBlendEquation)
Construct the blend mode given the factors and equation.
sf::BlendMode::BlendMode
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation=Equation::Add)
Construct the blend mode given the factors and equation.
sf::BlendMode::Equation
Equation
Enumeration of the blending equations.
Definition BlendMode.hpp:69
sf::BlendMode::Equation::Subtract
@ Subtract
Pixel = Src * SrcFactor - Dst * DstFactor.
Definition BlendMode.hpp:71
sf::BlendMode::Equation::Max
@ Max
Pixel = max(Dst, Src)
Definition BlendMode.hpp:74
sf::BlendMode::Equation::Min
@ Min
Pixel = min(Dst, Src)
Definition BlendMode.hpp:73
sf::BlendMode::Equation::ReverseSubtract
@ ReverseSubtract
Pixel = Dst * DstFactor - Src * SrcFactor.
Definition BlendMode.hpp:72
sf::BlendMode::Equation::Add
@ Add
Pixel = Src * SrcFactor + Dst * DstFactor.
Definition BlendMode.hpp:70
sf::BlendMode::alphaSrcFactor
Factor alphaSrcFactor
Source blending factor for the alpha channel.
Definition BlendMode.hpp:122
sf::BlendMode::alphaDstFactor
Factor alphaDstFactor
Destination blending factor for the alpha channel.
Definition BlendMode.hpp:123
sf::BlendMode::colorDstFactor
Factor colorDstFactor
Destination blending factor for the color channels.
Definition BlendMode.hpp:120
sf::BlendMode::colorEquation
Equation colorEquation
Blending equation for the color channels.
Definition BlendMode.hpp:121
sf::BlendMode::operator!=
bool operator!=(const BlendMode &left, const BlendMode &right)
Overload of the operator!=
sf::BlendMode::Factor
Factor
Enumeration of the blending factors.
Definition BlendMode.hpp:49
sf::BlendMode::Factor::One
@ One
(1, 1, 1, 1)
Definition BlendMode.hpp:51
sf::BlendMode::Factor::OneMinusSrcColor
@ OneMinusSrcColor
(1, 1, 1, 1) - (src.r, src.g, src.b, src.a)
Definition BlendMode.hpp:53
sf::BlendMode::Factor::OneMinusDstColor
@ OneMinusDstColor
(1, 1, 1, 1) - (dst.r, dst.g, dst.b, dst.a)
Definition BlendMode.hpp:55
sf::BlendMode::Factor::SrcColor
@ SrcColor
(src.r, src.g, src.b, src.a)
Definition BlendMode.hpp:52
sf::BlendMode::Factor::OneMinusDstAlpha
@ OneMinusDstAlpha
(1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a)
Definition BlendMode.hpp:59
sf::BlendMode::Factor::OneMinusSrcAlpha
@ OneMinusSrcAlpha
(1, 1, 1, 1) - (src.a, src.a, src.a, src.a)
Definition BlendMode.hpp:57
sf::BlendMode::Factor::SrcAlpha
@ SrcAlpha
(src.a, src.a, src.a, src.a)
Definition BlendMode.hpp:56
sf::BlendMode::Factor::Zero
@ Zero
(0, 0, 0, 0)
Definition BlendMode.hpp:50
sf::BlendMode::Factor::DstAlpha
@ DstAlpha
(dst.a, dst.a, dst.a, dst.a)
Definition BlendMode.hpp:58
sf::BlendMode::Factor::DstColor
@ DstColor
(dst.r, dst.g, dst.b, dst.a)
Definition BlendMode.hpp:54