Gamedev Framework (gf)  0.1.0
A C++11 framework for 2D games
Effects.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * 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
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_EFFECTS_H
22 #define GF_EFFECTS_H
23 
24 #include "Effect.h"
25 #include "Portability.h"
26 
27 namespace gf {
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 inline namespace v1 {
30 #endif
31 
32  /**
33  * @ingroup graphics
34  * @brief Default effect
35  *
36  * This post-processing effect does nothing
37  */
38  class GF_API DefaultEffect : public Effect {
39  public:
40  /**
41  * @brief Default constructor
42  */
43  DefaultEffect();
44  };
45 
46 
47  /**
48  * @ingroup graphics
49  * @brief Anti-aliasing effect
50  *
51  * This effect uses [Fast Approximate Anti-Aliasing (FXAA)](https://en.wikipedia.org/wiki/Fast_approximate_anti-aliasing).
52  */
53  class GF_API AntiAliasingEffect : public Effect {
54  public:
55  /**
56  * @brief Default constructor
57  */
59 
60  /**
61  * @brief Set the framebuffer size
62  *
63  * Call this function when the size of the framebuffer changes.
64  */
65  void setFramebufferSize(Vector2f size);
66  };
67 
68 
69  /**
70  * @ingroup graphics
71  * @brief Generic color matrix effect
72  *
73  * This effect uses a color matrix. You can use it directly or use a
74  * subclass that defines their own color matrix for various needs.
75  *
76  * @sa gf::ColorEffect, gf::ColorBlindEffect
77  */
78  class GF_API ColorMatrixEffect : public Effect {
79  public:
80  /**
81  * @brief Default constructor
82  */
84 
85  /**
86  * @brief Set the color matrix
87  *
88  * You can use this function to set your own color matrix.
89  * The color of the texture is left-multiplied by the color
90  * matrix to get the final color.
91  *
92  * @param mat The color matrix
93  */
94  void setColorMatrix(const Matrix4f& mat);
95  };
96 
97  /**
98  * @ingroup graphics
99  * @brief Simple color effects
100  */
102  public:
103  /**
104  * @brief Type of color effect
105  */
106  enum Type {
107  Normal, ///< No effect
108  Grayscale, ///< Grayscale
109  Sepia, ///< Sepia colors
110  NightVision, ///< Night vision
111  Warm, ///< Warm colors
112  Cool, ///< Cool colors
113  };
114 
115  /**
116  * @brief Constructor
117  *
118  * @param type The type of color blindness
119  */
120  ColorEffect(Type type);
121 
122  /**
123  * @brief Change the type of color effect
124  *
125  * @param type The type of color effect
126  */
127  void setType(Type type);
128  };
129 
130  /**
131  * @ingroup graphics
132  * @brief Simulation of color blindness
133  *
134  * [Color blindness](https://en.wikipedia.org/wiki/Color_blindness) is a
135  * deficiency of the vision that affects a significant percentage of the
136  * population.
137  *
138  * This effect simulate different types of color blindness.
139  */
141  public:
142  /**
143  * @brief Type of color blindness
144  */
145  enum Type {
146  Normal, ///< Normal vision
147  Protanopia, ///< Protanopia (red dichromacy, 1% of males affected)
148  Protanomaly, ///< Protanomaly (red trichromacy, 1% of males affected)
149  Deuteranopia, ///< Deuteranopia (green dichromacy, 1% of males affected)
150  Deuteranomaly, ///< Deuteranomaly (green trichromacy, 6% of males affected)
151  Tritanopia, ///< Tritanopia (blue dichromacy, rare)
152  Tritanomaly, ///< Tritanomaly (blue trichromacy, very rare)
153  Achromatopsia, ///< Achromatopsia (rod monochromacy, very rare)
154  Achromatomaly, ///< Achromatomaly (blue cone monochromacy, very rare)
155  };
156 
157  /**
158  * @brief Constructor
159  *
160  * @param type The type of color blindness
161  */
162  ColorBlindEffect(Type type = Normal);
163 
164  /**
165  * @brief Change the type of color blindness
166  *
167  * @param type The type of color blindness
168  */
169  void setType(Type type);
170  };
171 
172 
173  /**
174  * @ingroup graphics
175  * @brief Edge detector
176  *
177  * This effect uses a [Sobel filter](https://en.wikipedia.org/wiki/Sobel_operator).
178  *
179  */
180  class GF_API EdgeEffect : public Effect {
181  public:
182  /**
183  * @brief Default constructor
184  */
185  EdgeEffect();
186 
187  /**
188  * @brief Set the framebuffer size
189  *
190  * Call this function when the size of the framebuffer changes.
191  */
192  void setFramebufferSize(Vector2f size);
193  };
194 
195 }
196 }
197 
198 #endif // GF_EFFECTS_H
Warm colors.
Definition: Effects.h:111
void setFramebufferSize(Vector2f size)
Set the framebuffer size.
Vector< float, 2 > Vector2f
A float vector with 2 components.
Definition: Vector.h:741
Achromatomaly (blue cone monochromacy, very rare)
Definition: Effects.h:154
Deuteranomaly (green trichromacy, 6% of males affected)
Definition: Effects.h:150
void setColorMatrix(const Matrix4f &mat)
Set the color matrix.
Night vision.
Definition: Effects.h:110
Tritanopia (blue dichromacy, rare)
Definition: Effects.h:151
Edge detector.
Definition: Effects.h:180
ColorBlindEffect(Type type=Normal)
Constructor.
Generic color matrix effect.
Definition: Effects.h:78
Tritanomaly (blue trichromacy, very rare)
Definition: Effects.h:152
Type
Type of color effect.
Definition: Effects.h:106
void setType(Type type)
Change the type of color effect.
Definition: Action.h:34
Protanomaly (red trichromacy, 1% of males affected)
Definition: Effects.h:148
No effect.
Definition: Effects.h:107
ColorEffect(Type type)
Constructor.
Normal vision.
Definition: Effects.h:146
ColorMatrixEffect()
Default constructor.
Protanopia (red dichromacy, 1% of males affected)
Definition: Effects.h:147
Simulation of color blindness.
Definition: Effects.h:140
void setType(Type type)
Change the type of color blindness.
Achromatopsia (rod monochromacy, very rare)
Definition: Effects.h:153
Deuteranopia (green dichromacy, 1% of males affected)
Definition: Effects.h:149
void setFramebufferSize(Vector2f size)
Set the framebuffer size.
Sepia colors.
Definition: Effects.h:109
Matrix< float, 4, 4 > Matrix4f
A float square matrix of size 4.
Definition: Matrix.h:334
A post-processing effect.
Definition: Effect.h:38
EdgeEffect()
Default constructor.
Simple color effects.
Definition: Effects.h:101
#define GF_API
Definition: Portability.h:35
DefaultEffect()
Default constructor.
Type
Type of color blindness.
Definition: Effects.h:145
Default effect.
Definition: Effects.h:38
Grayscale.
Definition: Effects.h:108
AntiAliasingEffect()
Default constructor.
Cool colors.
Definition: Effects.h:112
Anti-aliasing effect.
Definition: Effects.h:53