BlendMode.cpp
1// Copyright 2019 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4
5#include <smk/BlendMode.hpp>
6
7namespace smk {
8
9/// @brief destination = source.
10const BlendMode BlendMode::Replace = {
11 GL_FUNC_ADD, GL_FUNC_ADD, GL_ONE, GL_ZERO, GL_ONE, GL_ZERO,
12};
13
14/// @brief destination += source.
15const BlendMode BlendMode::Add = {
16 GL_FUNC_ADD, GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE,
17};
18
19/// @brief destination -= source.
20const BlendMode BlendMode::Subtract = {
21 GL_FUNC_REVERSE_SUBTRACT,
22 GL_FUNC_REVERSE_SUBTRACT,
23 GL_ONE,
24 GL_ONE,
25 GL_ONE,
26 GL_ONE,
27};
28
29/// @brief destination = source * source.a + destination * (1 - souce.a)
30const BlendMode BlendMode::Alpha = {
31 GL_FUNC_ADD, GL_FUNC_ADD,
32 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
33 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
34};
35
36/// @brief destination *= source
37const BlendMode BlendMode::Multiply = {
38 GL_FUNC_ADD, GL_FUNC_ADD, GL_DST_COLOR, GL_ZERO, GL_DST_ALPHA, GL_ZERO,
39};
40
41/// @brief destination = 1 - destination
42const BlendMode BlendMode::Invert = {
43 GL_FUNC_ADD,
44 GL_FUNC_ADD,
45 GL_ONE_MINUS_DST_COLOR,
46 GL_ZERO,
47 GL_ONE_MINUS_SRC_ALPHA,
48 GL_ZERO,
49};
50
51bool BlendMode::operator==(const BlendMode& o) const {
52 return equation_rgb == o.equation_rgb && //
53 equation_alpha == o.equation_alpha && //
54 src_rgb == o.src_rgb && //
55 dst_rgb == o.dst_rgb && //
56 src_alpha == o.src_alpha && //
57 dst_alpha == o.dst_alpha; //
58}
59
60bool BlendMode::operator!=(const BlendMode& o) const {
61 return !operator==(o);
62}
63
64} // namespace smk
static const BlendMode Add
destination += source.
Definition: BlendMode.hpp:65
static const BlendMode Subtract
destination -= source.
Definition: BlendMode.hpp:66
static const BlendMode Multiply
destination *= source
Definition: BlendMode.hpp:67
static const BlendMode Replace
destination = source.
Definition: BlendMode.hpp:64
static const BlendMode Alpha
destination = source * source.a + destination * (1 - souce.a)
Definition: BlendMode.hpp:68
static const BlendMode Invert
destination = 1 - destination
Definition: BlendMode.hpp:69