summaryrefslogtreecommitdiff
path: root/inc/opengl/spritebatch.hpp
blob: 94ca97c7f335b33fe3b203dfd8cd6dd6a8e82d8a (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
#ifndef spritebatch_h
#define spritebatch_h

#include <GL/glew.h>
#include "graphicsdata.hpp"
#include <vector>
#include "geoshader.hpp"
#include <iostream>


class RenderBatch {
        public:
                RenderBatch(GLuint Offset, GLuint NumVertices) : offset(Offset),
                numVertices(NumVertices){}
                GLuint offset;
                GLuint numVertices;
};

class SpriteBatch
{
        public:
                SpriteBatch(GeoShader theshader);
                ~SpriteBatch();

                void init();
                void begin();
                void end();
                void draw(const GraphicsData& gfxData);
                void renderBatch();

        private:
                void createRenderBatches();
                void createVertexArray();
                
                GLuint _vbo;
                GLuint _vao;

                std::vector<GraphicsData*> _gfxPtr; ///< This is for sorting
                std::vector<GraphicsData> _gfx; ///< These are the actual glyphs
                std::vector<RenderBatch> _renderBatches;

                GeoShader shader;
};

#endif