blob: 3ece593cc6952e032d05e569059cb098e858c39c (
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
53
54
55
56
57
58
59
60
61
62
63
|
#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;
//GLuint texture;
};
class SpriteBatch
{
public:
SpriteBatch(GeoShader theshader);
~SpriteBatch();
// Initializes the spritebatch
void init();
// Begins the spritebatch
void begin();
// Ends the spritebatch
void end();
// Adds a glyph to the spritebatch
void draw(const GraphicsData& gfxData);
// Renders the entire SpriteBatch to the screen
void renderBatch();
private:
// Creates all the needed RenderBatches
void createRenderBatches();
// Generates our VAO and VBO
void createVertexArray();
// Sorts glyphs according to _sortType
//void sortGlyphs();
// Comparators used by sortGlyphs()
//static bool compareFrontToBack(Glyph* a, Glyph* b);
//static bool compareBackToFront(Glyph* a, Glyph* b);
//static bool compareTexture(Glyph* a, Glyph* b);
GLuint _vbo;
GLuint _vao;
//GlyphSortType _sortType;
std::vector<GraphicsData*> _gfxPtr; ///< This is for sorting
std::vector<GraphicsData> _gfx; ///< These are the actual glyphs
std::vector<RenderBatch> _renderBatches;
GeoShader shader;
};
#endif
|