-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite.hpp
44 lines (34 loc) · 838 Bytes
/
sprite.hpp
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
#ifndef PANZERTOY_SPRITE_HPP
#define PANZERTOY_SPRITE_HPP
#include <string>
#include <glm/glm.hpp>
#include "shader.hpp"
#include "texture.hpp"
struct SpriteRenderInfos {
Shader shader;
GLuint VAO, VBO, EBO;
};
/**
* @class Sprite
*
* @brief Represents a drawable and textured 2D sprite
*/
class Sprite {
public:
Sprite() = default;
Sprite(const std::string& filename) { load(filename); };
static void init(SpriteRenderInfos& infos);
// @TODO: Make a pointer to SpriteRenderInfos
void load(const std::string& filename);
void draw(SpriteRenderInfos& infos);
void set_pos(const glm::ivec2& pos);
void set_size(glm::ivec2 size);
private:
float vertices[4][4] = {};
bool dirty = true;
Texture texture;
glm::ivec2 pos = glm::ivec2(0);
glm::ivec2 size;
void calculate_vertices();
};
#endif // PANZERTOY_SPRITE_HPP