RendererGL.hpp
3.7 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
/*
TE4 - T-Engine 4
Copyright (C) 2009 - 2015 Nicolas Casalini
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Nicolas Casalini "DarkGod"
darkgod@te4.org
*/
#ifndef RENDERER_GL_H
#define RENDERER_GL_H
#include "displayobjects/Renderer.hpp"
class RendererGL;
class DisplayList;
class DORContainer;
/****************************************************************************
** Display lists contain a VBO, texture, ... and a list of vertices to be
** drawn; those dont change and dont get recomputed until needed
****************************************************************************/
class DisplayList {
public:
int used = 0;
GLuint vbo = 0;
GLuint tex = 0;
shader_type *shader = NULL;
vector<vertex> list;
DisplayList();
~DisplayList();
};
/****************************************************************************
** Base GL display object
****************************************************************************/
class DisplayObjectGL {
protected:
GLuint mode;
GLenum kind;
public:
vector<vertex> list;
DisplayObjectGL();
virtual ~DisplayObjectGL();
virtual void render(DORContainer *container, mat4 cur_model) = 0;
};
/****************************************************************************
** GL DO for simple vertexes lists
****************************************************************************/
class DORVertexes : public DOVertexes, public DisplayObjectGL {
public:
DORVertexes() : DOVertexes(), DisplayObjectGL() {};
virtual ~DORVertexes() {};
virtual void render(DORContainer *container, mat4 cur_model);
};
/****************************************************************************
** GL DO for text
****************************************************************************/
class DORText : public DOText, public DisplayObjectGL {
public:
DORText() : DOText(), DisplayObjectGL() {};
virtual ~DORText() {};
virtual void render(DORContainer *container, mat4 cur_model);
};
/****************************************************************************
** GL DO Container, the base of the rendering pyramid
****************************************************************************/
class DORContainer : public DOContainer, public DisplayObjectGL {
protected:
vector<DisplayList*> displays;
int nb_quads = 0;
public:
DORContainer() : DOContainer(), DisplayObjectGL() {};
virtual ~DORContainer() {};
virtual void render(DORContainer *container, mat4 cur_model);
virtual void addDisplayList(DisplayList* dl) {
displays.push_back(dl);
}
};
/****************************************************************************
** Handling actual rendering to the screen & such
****************************************************************************/
class RendererGL : public Renderer, public DORContainer {
private:
RendererState *state;
GLuint *vbo_elements_data = NULL;
GLuint vbo_elements = 0;
int vbo_elements_nb = 0;
bool zsort = false;
vector<vertex> zvertices;
public:
RendererGL();
RendererGL(int w, int h);
virtual ~RendererGL();
virtual void zSorting(bool sort) { zsort = sort; };
virtual void update();
virtual void toScreen(float x, float y, float r, float g, float b, float a);
};
#endif