/
Square.h
51 lines (37 loc) · 913 Bytes
/
Square.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
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef SQUARE_H
#define SQUARE_H
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <vector>
class Square
{
public:
Square( QOpenGLShaderProgram *program,
int vertexAttr,
int textureAttr,
int textureUniform );
~Square();
enum Direction { Left, Up, Right, Down };
Direction direction() const;
void setDirection( Direction dir );
void draw();
void setX0( float x );
void setY0( float y );
float x0() const;
float y0() const;
private:
void initVertices();
void initTextureCoords();
std::vector<float> m_vertices;
std::vector<float> m_textureCoords;
QOpenGLShaderProgram *m_program;
int m_vertexAttr;
int m_textureAttr;
int m_textureUniform;
float m_x0;
float m_y0;
const float m_size;
Direction m_direction;
QOpenGLTexture *m_texture;
};
#endif // SQUARE_H