aboutsummaryrefslogtreecommitdiffstats
path: root/include/YAGE/spritebatch.hpp
blob: fcc6faec338d43381f9615e6d20f024288cfb68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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