-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrenderer2d.hpp
More file actions
136 lines (130 loc) · 5.36 KB
/
renderer2d.hpp
File metadata and controls
136 lines (130 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#pragma once
#include <fea/config.hpp>
#include <fea/rendering/color.hpp>
#include <fea/rendering/viewport.hpp>
#include <fea/rendering/rendertarget.hpp>
#include <fea/rendering/shader.hpp>
#include <fea/rendering/renderentity.hpp>
#include <memory>
namespace fea
{
class Drawable2D;
class FEA_API Renderer2D
{
public:
Renderer2D(const Viewport& viewport);
void clear(const Color& color = Color());
void clear(const RenderTarget& target, const Color& color = Color());
template<typename Drawable>
void render(const Drawable& drawable);
template<typename Drawable>
void render(const Drawable& drawable, const RenderTarget& target);
template<typename Drawable>
void render(const Drawable& drawable, Shader& shader);
template<typename Drawable>
void render(const Drawable& drawable, const RenderTarget& target, Shader& shader);
void setViewport(const Viewport& viewport);
const Viewport& getViewport() const;
Viewport& getViewport();
void setBlendMode(BlendMode mode);
private:
void setBlendModeGl(BlendMode mode);
Viewport mCurrentViewport;
Texture mDefaultTexture;
GLuint mVertexArray;
Shader mDefaultShader;
glm::mat4 mProjection;
BlendMode mCurrentBlendMode;
//cache
Color mClearColor;
};
#include <fea/rendering/renderer2d.inl>
/** @addtogroup Render2D
*@{
* @class InvalidFontException
* @class Renderer2D
*@}
***
* @class InvalidFontException
* @brief Exception used when something has gone wrong with font handling.
***
* @fn InvalidFontException::InvalidFontException(const std::string& message)
* @brief Construct an exception to throw containing a message.
* @param message Message further describing the error.
***
* @class Renderer2D
* @brief Used to render 2D drawables to the screen.
*
* This class provides a complete interface for rendering to the screen.
*
* The Renderer2D keeps a Viewport describing the size of the render area as well as the current camera data.
*
* Important: A valid OpenGL context must exist to be able to construct the renderer.
***
* @fn Renderer2D::Renderer2D(Viewport viewport)
* @brief Construct a renderer with the given Viewport.
*
* @param viewport Viewport to use.
***
* @fn void Renderer2D::clear(const Color& color = Color())
* @brief Clear the screen, filling it with the given color.
*
* Usually called once every frame as a first step of the rendering process to clear out what was drawn the last frame.
* @param color Color object. Black by default.
***
* @fn void Renderer2D::clear(const RenderTarget& target, const Color& = Color())
* @brief Clear the given RenderTarget, filling it with the given color.
*
* Usually called once every frame as a first step of the rendering process to clear out what was drawn the last frame.
* @param target RenderTarget to clear.
* @param color Color object. Black by default.
***
* @fn void Renderer2D::render(const Drawable& drawable)
* @brief Render drawable to the screen.
*
* Can take any object which implements a public method getRenderInfo which returns an iterable container of RenderEntity objects. The Drawable2D class fits this criteria. The drawable will be rendered offset and transformed depending on the current Viewport of the renderer.
* @param drawable Drawable to render.
***
* @fn void Renderer2D::render(const Drawable& drawable, const RenderTarget& target)
* @brief Render drawable to a RenderTarget.
*
* @param drawable Drawable to render.
* @param target RenderTarget to render to.
***
* @fn void Renderer2D::render(const Drawable& drawable, Shader& shader)
* @brief Render drawable using a custom shader.
*
* @param drawable Drawable to render.
* @param shader Shader object to use.
***
* @fn void Renderer2D::render(const Drawable& drawable, const RenderTarget& target, Shader& shader)
* @brief Render drawable to a RenderTarget using a custom shader.
*
* @param drawable Drawable to render.
* @param target RenderTarget to render to.
* @param shader Shader object to use.
***
* @fn void Renderer2D::setViewport(const Viewport& viewport)
* @brief Set the Viewport of the renderer
* @param viewport Viewport to set it to.
***
* @fn const Viewport& Renderer2D::getViewport() const
* @brief Access the current Viewport.
*
* Returns a reference, so this can be used to modify the Viewport.
* @return A reference to the Viewport.
***
* @fn Viewport& Renderer2D::getViewport()
* @brief Access the current Viewport.
*
* Returns a reference, so this can be used to modify the Viewport.
* @return A reference to the Viewport.
***
* @fn void Renderer2D::setBlendMode(BlendMode mode)
* @brief Set which blend mode to use.
*
* The blend mode decides how drawables are blended with the background when they are drawn.
*
* @param mode Blend mode.
***/
}