-
Notifications
You must be signed in to change notification settings - Fork 5
/
sprite.h
38 lines (32 loc) · 1.02 KB
/
sprite.h
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
#ifndef SPRITE_HEADER
#define SPRITE_HEADER
#include <glm/glm.hpp>
#include "../common/util.h"
class Sprite
{
public:
Sprite(GLuint texture, int textureWidth, int textureHeight);
~Sprite();
void setPosition(float x, float y, float z);
void setScale(float x, float y);
void setAngle(float angle);
void setTextureRectangle(int x, int y, int w, int h);
void setColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
GLuint getTexture() const;
const glm::mat4& getModelMatrix();
void getTextureRectangle(int* x, int* y, int* w, int* h) const;
void getColor(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) const;
void getTextureDimensions(int* tW, int* tH);
bool compare(const Sprite& other) const;
private:
bool dirty;
GLuint texture;
glm::vec2 scale;
float angle;
glm::vec3 position;
unsigned char r, g, b, a;
glm::mat4 model;
int x, y, w, h; // Texture rectangle
int textureWidth, textureHeight;
};
#endif