aboutsummaryrefslogtreecommitdiffstats
path: root/include/YAGE/spritebatch.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/YAGE/spritebatch.hpp')
-rw-r--r--include/YAGE/spritebatch.hpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/include/YAGE/spritebatch.hpp b/include/YAGE/spritebatch.hpp
index a3007bbf..9446c40f 100644
--- a/include/YAGE/spritebatch.hpp
+++ b/include/YAGE/spritebatch.hpp
@@ -16,13 +16,11 @@
#include <vector>
-namespace yage
-{
+namespace yage {
class SpriteBatch;
-class Glyph
-{
+class Glyph {
// member variables
private:
GLuint texture_;
@@ -34,7 +32,9 @@ private:
// member functions
public:
- Glyph(GLuint texture, float depth, const Vertex &top_left, const Vertex &top_right, const Vertex &bottom_right, const Vertex &bottom_left);
+ Glyph(GLuint texture, float depth, const Vertex& top_left,
+ const Vertex& top_right, const Vertex& bottom_right,
+ const Vertex& bottom_left);
GLuint texture() const { return texture_; }
float depth() const { return depth_; }
@@ -44,12 +44,11 @@ public:
Vertex bottom_left() const { return bottom_left_; }
};
-class RenderBatch
-{
+class RenderBatch {
friend SpriteBatch;
// member variables
private:
- GLsizei num_vertices_;
+ GLsizei num_vertices_;
GLint offset_;
GLuint texture_;
@@ -63,42 +62,44 @@ public:
GLuint texture() const { return texture_; }
};
-class SpriteBatch
-{
+class SpriteBatch {
// member variables
public:
- static const int NUM_VERTICES=6;
+ static const int NUM_VERTICES = 6;
+
private:
- GLuint vbo_=0;
- GLuint vao_=0;
+ GLuint vbo_ = 0;
+ GLuint vao_ = 0;
std::vector<Glyph> glyphs_;
- std::vector<Glyph *> glyph_ptrs_;
+ std::vector<Glyph*> glyph_ptrs_;
std::vector<RenderBatch> render_batches_;
// member functions
public:
SpriteBatch();
- SpriteBatch(const SpriteBatch&)=delete;
- SpriteBatch(SpriteBatch&&)=delete;
+ SpriteBatch(const SpriteBatch&) = delete;
+ SpriteBatch(SpriteBatch&&) = delete;
~SpriteBatch();
- SpriteBatch& operator=(const SpriteBatch&)=delete;
- SpriteBatch& operator=(SpriteBatch&&)=delete;
+ SpriteBatch& operator=(const SpriteBatch&) = delete;
+ SpriteBatch& operator=(SpriteBatch&&) = delete;
// initialize vaos and vbos
void init();
void begin();
void end();
// adds a sprite to the sprite batch to be rendered later
- void draw(const glm::vec4 &destination_rect, const glm::vec4 &uv_rect, GLuint texture, const Color &color, float depth);
+ void draw(const glm::vec4& destination_rect, const glm::vec4& uv_rect,
+ GLuint texture, const Color& color, float depth);
// render the batch
void render();
+
private:
void createVertexArray();
void createRenderBatches();
void sortGlyphs();
};
-
-} // yage
+
+} // yage
#endif