16
16
#include " debugTexture_fs.h"
17
17
18
18
namespace Tangram {
19
-
20
- namespace Primitives {
19
+ namespace Debug {
21
20
22
21
static bool s_initialized;
23
22
static std::unique_ptr<ShaderProgram> s_shader;
@@ -32,7 +31,7 @@ static std::unique_ptr<VertexLayout> s_textureLayout;
32
31
33
32
static UniformLocation s_uTextureProj{" u_proj" };
34
33
35
- void init () {
34
+ void Primitives:: init () {
36
35
37
36
// lazy init
38
37
if (!s_initialized) {
@@ -60,7 +59,7 @@ void init() {
60
59
}
61
60
}
62
61
63
- void deinit () {
62
+ void Primitives:: deinit () {
64
63
65
64
s_shader.reset (nullptr );
66
65
s_layout.reset (nullptr );
@@ -70,7 +69,7 @@ void deinit() {
70
69
71
70
}
72
71
73
- void drawLine (RenderState& rs, const glm::vec2& _origin, const glm::vec2& _destination) {
72
+ void Primitives:: drawLine (RenderState& rs, const glm::vec2& _origin, const glm::vec2& _destination) {
74
73
75
74
init ();
76
75
@@ -94,14 +93,14 @@ void drawLine(RenderState& rs, const glm::vec2& _origin, const glm::vec2& _desti
94
93
rs.vertexBuffer (boundBuffer);
95
94
}
96
95
97
- void drawRect (RenderState& rs, const glm::vec2& _origin, const glm::vec2& _destination) {
96
+ void Primitives:: drawRect (RenderState& rs, const glm::vec2& _origin, const glm::vec2& _destination) {
98
97
drawLine (rs, _origin, {_destination.x , _origin.y });
99
98
drawLine (rs, {_destination.x , _origin.y }, _destination);
100
99
drawLine (rs, _destination, {_origin.x , _destination.y });
101
100
drawLine (rs, {_origin.x ,_destination.y }, _origin);
102
101
}
103
102
104
- void drawPoly (RenderState& rs, const glm::vec2* _polygon, size_t _n) {
103
+ void Primitives:: drawPoly (RenderState& rs, const glm::vec2* _polygon, size_t _n) {
105
104
init ();
106
105
107
106
if (!s_shader->use (rs)) { return ; }
@@ -119,7 +118,7 @@ void drawPoly(RenderState& rs, const glm::vec2* _polygon, size_t _n) {
119
118
rs.vertexBuffer (boundBuffer);
120
119
}
121
120
122
- void drawTexture (RenderState& rs, Texture& _tex, glm::vec2 _pos, glm::vec2 _dim) {
121
+ void Primitives:: drawTexture (RenderState& rs, Texture& _tex, glm::vec2 _pos, glm::vec2 _dim) {
123
122
init ();
124
123
125
124
if (!s_textureShader->use (rs)) { return ; }
@@ -156,7 +155,7 @@ void drawTexture(RenderState& rs, Texture& _tex, glm::vec2 _pos, glm::vec2 _dim)
156
155
rs.vertexBuffer (boundBuffer);
157
156
}
158
157
159
- void setColor (RenderState& rs, unsigned int _color) {
158
+ void Primitives:: setColor (RenderState& rs, unsigned int _color) {
160
159
init ();
161
160
162
161
float r = (_color >> 16 & 0xff ) / 255.0 ;
@@ -166,7 +165,7 @@ void setColor(RenderState& rs, unsigned int _color) {
166
165
s_shader->setUniformf (rs, s_uColor, r, g, b);
167
166
}
168
167
169
- void setResolution (RenderState& rs, float _width, float _height) {
168
+ void Primitives:: setResolution (RenderState& rs, float _width, float _height) {
170
169
init ();
171
170
172
171
glm::mat4 proj = glm::ortho (0 .f , _width, _height, 0 .f , -1 .f , 1 .f );
@@ -175,5 +174,5 @@ void setResolution(RenderState& rs, float _width, float _height) {
175
174
}
176
175
177
176
}
178
-
179
177
}
178
+
0 commit comments