diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-04-04 12:19:41 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-04-04 12:19:41 +0100 |
commit | 55a1e0ad7c9d2661c266b2e767bfcb2f944e859f (patch) | |
tree | fe3ac90ab853e2f87bd33294976a3fc56e144988 /include/YAGE/spritebatch.hpp | |
parent | aa67c8bb56cb750ac83ecbd361439f5ecb5e12d9 (diff) | |
download | YAGE-55a1e0ad7c9d2661c266b2e767bfcb2f944e859f.tar.gz YAGE-55a1e0ad7c9d2661c266b2e767bfcb2f944e859f.zip |
Adding spritebatch class
Diffstat (limited to 'include/YAGE/spritebatch.hpp')
-rw-r--r-- | include/YAGE/spritebatch.hpp | 52 |
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 |