1 #ifndef NTA_SPRITEBATCH_H_INCLUDED
2 #define NTA_SPRITEBATCH_H_INCLUDED
6 #include "nta/Vertex.h"
9 #define NTA_DEFAULT_DEPTH 0.5
14 Glyph(crvec4 posRect, crvec4 uvRect, GLuint texture,
float d, crvec4 color) :
19 topLeft.hasTexture = texture != 0;
20 topRight.
setPosition(posRect.x + posRect[2], posRect.y);
21 topRight.
setUV(uvRect.x + uvRect[2], uvRect.y);
22 topRight.color = color;
23 topRight.hasTexture = texture != 0;
24 botRight.
setPosition(posRect.x + posRect[2], posRect.y - posRect[3]);
25 botRight.
setUV(uvRect.x + uvRect[2], uvRect.y + uvRect[3]);
26 botRight.color = color;
27 botRight.hasTexture = texture != 0;
28 botLeft.
setPosition(posRect.x, posRect.y - posRect[3]);
29 botLeft.
setUV(uvRect.x, uvRect.y + uvRect[3]);
30 botLeft.color = color;
31 botLeft.hasTexture = texture != 0;
34 Glyph(crvec4 posRect, crvec4 uvRect, GLuint tex,
float d, crvec4 col,
float angle) :
36 glm::vec2 extents(posRect[2]/2.f, posRect[3]/2.f), pos(posRect.x, posRect.y);
37 glm::vec2 tl(-extents.x, extents.y), tr(extents.x, extents.y),
38 bl(-extents.x, -extents.y), br(extents.x, -extents.y);
45 topRight.
setUV(uvRect.x + uvRect[2], uvRect.y);
47 topRight.hasTexture = tex != 0;
49 botRight.
setUV(uvRect.x + uvRect[2], uvRect.y + uvRect[3]);
51 botRight.hasTexture = tex != 0;
53 botLeft.
setUV(uvRect.x, uvRect.y + uvRect[3]);
55 botLeft.hasTexture = tex != 0;
70 RenderBatch(GLuint t, GLuint o, GLuint n, GLenum m = GL_TRIANGLES) :
97 static bool compareDepth(
Glyph* lhs,
Glyph* rhs);
119 void addGlyph(crvec4 posRect, GLuint texture = 0,
120 crvec4 uvRect = glm::vec4(0,0,1,1),
121 crvec4 color = glm::vec4(1),
122 float depth = NTA_DEFAULT_DEPTH);
123 void addGlyph(crvec4 posRect, crvec4 uvRect, GLuint texture,
124 float depth = NTA_DEFAULT_DEPTH, crvec4 color = glm::vec4(1));
125 void addGlyph(crvec2 corner1, crvec2 corner2, crvec4 uvRect, GLuint texture,
126 float depth = NTA_DEFAULT_DEPTH, crvec4 color = glm::vec4(1));
127 void addGlyph(crvec4 posRect, crvec4 uvRect, GLuint texture, crvec4 color,
128 float angle = 0.0f,
float depth = NTA_DEFAULT_DEPTH);
129 void addGlyph(crvec2 corner1, crvec2 corner2, crvec4 uvRect, GLuint texture, crvec4 color,
130 float angle = 0.0f,
float depth = NTA_DEFAULT_DEPTH);
136 #endif // NTA_SPRITEBATCH_H_INCLUDED