-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_text.h
58 lines (49 loc) · 1.43 KB
/
draw_text.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
53
54
55
56
57
58
#ifndef HEADER_DRAW_TEXT
#define HEADER_DRAW_TEXT
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <common.h>
#include <load_shader.h>
#include <ft2build.h>
#include FT_FREETYPE_H
struct AtlasCharacter {
float ax; // advance.x
float ay; // advance.y
float bw; // bitmap.width;
float bh; // bitmap.rows;
float bl; // bitmap_left;
float bt; // bitmap_top;
float tx; // x offset of glyph in texture coordinates
};
typedef struct AtlasCharacter AtlasCharacter;
struct Atlas {
AtlasCharacter* characters;
unsigned int width;
unsigned int height;
GLuint tex;
unsigned int count;
unsigned long start;
};
typedef struct Atlas Atlas;
struct DrawableText {
GLuint* elements;
unsigned int elements_count;
GLfloat* vertices;
unsigned int vertices_count;
GLuint atlasTex;
GLuint shaderProgram;
GLuint vao;
};
typedef struct DrawableText DrawableText;
void printBitmap(FT_Bitmap bitmap);
GLuint compileTextShader();
//void createText(UsableShaderDataInput* shaderData);
Atlas createTextAtlas(unsigned long start, unsigned long end, const char* font_path, int width_px, int height_px);
DrawableText createDrawableTextUsingAtlas(wchar_t * text, Atlas* atlas, float x, float y, float sx, float sy);
void drawText(DrawableText * draw, ColorRGBAf color);
/* useless
unsigned long * charToULong(const char * text);
unsigned long * wcharToULong(const short * text);
*/
#endif