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.hpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/YAGE/spritebatch.hpp b/include/YAGE/spritebatch.hpp
new file mode 100644
index 00000000..fcc6faec
--- /dev/null
+++ b/include/YAGE/spritebatch.hpp
@@ -0,0 +1,52 @@
+#ifndef SPRITE_BATCH_HPP
+#define SPRITE_BATCH_HPP
+
+#include "vertex.hpp"
+
+#include <GL/glew.h>
+#include <glm/glm.hpp>
+
+#include <vector>
+
+namespace yage
+{
+
+struct Glyph
+{
+ GLuint texture;
+ float depth;
+
+ Vertex top_left;
+ Vertex top_right;
+ Vertex bottom_right;
+ Vertex bottom_left;
+};
+
+class SpriteBatch
+{
+public: // member variables
+private:
+ GLuint vbo_=0;
+ GLuint vao_=0;
+
+ std::vector<Glyph> glyphs_;
+ std::vector<Glyph *> glyph_ptrs_;
+
+public: // member functions
+ SpriteBatch();
+ ~SpriteBatch();
+
+ void begin();
+ void end();
+
+ void draw(const glm::vec4 &destination_rect, const glm::vec4 &uv_rect, GLuint texture, const Color &color, float depth);
+
+ void renderBatch();
+private:
+ void createVertexArray();
+ void sortGlyphs();
+};
+
+} // yage
+
+#endif