-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdrawer2D.h
52 lines (37 loc) · 981 Bytes
/
drawer2D.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
52
// drawer2D.h
#ifndef __DRAWER2D_H__
#define __DRAWER2D_H__
#include <GL/glew.h>
#include "utils.h"
// Simple class to draw strings in a [-1;1]x[-1;1] coordinates system
class Drawer2D
{
private:
GLuint m_id_vbo; // General-purpose VBO
// Unicolor shader
GLuint m_id_vert_color;
GLuint m_id_frag_color;
GLuint m_id_prog_color;
GLint m_id_uniform_color;
// Font
GLuint m_id_tex_font;
GLint m_id_uniform_tex_font;
GLint m_id_uniform_font_color;
GLuint m_id_vert_font;
GLuint m_id_frag_font;
GLuint m_id_prog_font;
// Window size
int m_win_w;
int m_win_h;
public:
Drawer2D() {}
bool init(int win_w, int win_h);
void shut();
void onResize(int win_w, int win_h) {m_win_w = win_w; m_win_h = win_h; }
void drawRect(const Rect& rect, const Color& color=COLOR_WHITE, float alpha=1.0f);
void drawString(const char* str, float x, float y, const Color& color=COLOR_WHITE);
private:
bool initFont();
};
extern Drawer2D drawer2D;
#endif // __DRAWER2D_H__