GA::kit v0.3
G&A's in-house C++ application framework
Loading...
Searching...
No Matches
render.h
Go to the documentation of this file.
1#pragma once
2#include "ga/color.h"
3#include "ga/math.h"
4#include <map>
5#include <vector>
6
7namespace ga {
8
9enum class MatrixType
10{
11 MODEL,
12 VIEW,
14};
15
17{
18public:
21
22 void setMatrix( const ga::mat4& matrix, MatrixType type = MatrixType::MODEL );
23 const ga::mat4& getMatrix( MatrixType type = MatrixType::MODEL );
24
25 void multMatrix( const ga::mat4& matrix, MatrixType type = MatrixType::MODEL );
26
27 // space helpers
28 void translate( const vec3& translation );
29 void translate( const vec2& translation );
30 void rotate( const quat& rotation );
31 void scale( const vec3& scale );
32
33 // color / style management
34 void setGlobalColor( const ga::Color& color );
36
37 // gl convenience functions
38 void clear( const ga::Color& color ); // clear fbo
39
40protected:
41 std::map<MatrixType, ga::mat4> m_matrices {
42 { MatrixType::MODEL, ga::mat4( 1.f ) },
43 { MatrixType::VIEW, ga::mat4( 1.f ) },
44 { MatrixType::PROJECTION, ga::mat4( 1.f ) } };
45 std::map<MatrixType, std::vector<ga::mat4>> m_matrixStack;
46 Color m_globalColor { 1.f, 1.f, 1.f, 1.f };
47};
48
49// singleton
51{
52 static Renderer r;
53 return r;
54}
55
57{
59 : m_type( type )
60 , m_renderer( &renderer )
61 {
62 m_renderer->pushMatrix( type );
63 }
65 {
67 }
68
69protected:
72};
73
74} // namespace ga
Definition: render.h:17
void translate(const vec3 &translation)
Definition: render.cpp:99
const ga::mat4 & getMatrix(MatrixType type=MatrixType::MODEL)
Definition: render.cpp:73
void setMatrix(const ga::mat4 &matrix, MatrixType type=MatrixType::MODEL)
Definition: render.cpp:52
Color m_globalColor
Definition: render.h:46
void pushMatrix(MatrixType type=MatrixType::MODEL)
Definition: render.cpp:10
void popMatrix(MatrixType type=MatrixType::MODEL)
Definition: render.cpp:28
void rotate(const quat &rotation)
Definition: render.cpp:109
void clear(const ga::Color &color)
Definition: render.cpp:132
void scale(const vec3 &scale)
Definition: render.cpp:114
const ga::Color & getGlobalColor()
Definition: render.cpp:127
std::map< MatrixType, ga::mat4 > m_matrices
Definition: render.h:41
void setGlobalColor(const ga::Color &color)
Definition: render.cpp:119
void multMatrix(const ga::mat4 &matrix, MatrixType type=MatrixType::MODEL)
Definition: render.cpp:78
std::map< MatrixType, std::vector< ga::mat4 > > m_matrixStack
Definition: render.h:45
Definition: color.h:9
ga::vec4 Color
Definition: color.h:12
MatrixType
Definition: render.h:10
Renderer & getRenderer()
Definition: render.h:50
Definition: render.h:57
MatrixType m_type
Definition: render.h:70
Renderer * m_renderer
Definition: render.h:71
~MatrixScope()
Definition: render.h:64
MatrixScope(MatrixType type=MatrixType::MODEL, Renderer &renderer=getRenderer())
Definition: render.h:58