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 {
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)
161// NOLINTEND(readability-identifier-naming)
162
163} // namespace sf
164
165
#define SFML_GRAPHICS_API
const BlendMode BlendMin
Take minimum between source and dest.
const BlendMode BlendAlpha
Blend source and dest according to dest alpha.
const BlendMode BlendAdd
Add source to dest.
const BlendMode BlendMax
Take maximum between source and dest.
const BlendMode BlendNone
Overwrite dest with source.
@ Zero
If the stencil test passes, the value in the stencil buffer is set to zero.
const BlendMode BlendMultiply
Multiply source and dest.
Blending modes for drawing.
Definition BlendMode.hpp:41
bool operator==(const BlendMode &left, const BlendMode &right)
Overload of the operator==
BlendMode()=default
Default constructor.
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
bool operator!=(const BlendMode &left, const BlendMode &right)
Overload of the operator!=
Factor
Enumeration of the blending factors.
Definition BlendMode.hpp:49