-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathPolyGlyph.h
More file actions
83 lines (62 loc) · 1.56 KB
/
Copy pathPolyGlyph.h
File metadata and controls
83 lines (62 loc) · 1.56 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <math.h>
#include <vector>
#include <string>
#include <map>
#include "GL/openglut.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#ifndef POLY_GLYPH_H
#define POLY_GLYPH_H
using namespace std;
class GlyphGeometry
{
public:
GlyphGeometry() {}
~GlyphGeometry() {}
template<class T>
class Vec3
{
public:
Vec3(T a, T b, T c) : x(a), y(b), z(c) {}
T x,y,z;
};
class Mesh
{
public:
Mesh(GLenum type) : m_Type(type) {}
~Mesh() {}
GLenum m_Type;
vector<Vec3<float> > m_Data;
};
GLenum m_Error;
vector<Mesh> m_Meshes;
vector<double*> m_CombinedVerts;
};
class PolyGlyph
{
public:
PolyGlyph(const string &ttffile);
~PolyGlyph();
void Render(wchar_t ch, float r, float g, float b, float a, float dx = 0, float dy = 0);
float CharacterWidth(wchar_t ch);
float CharacterHeight(wchar_t ch);
void ClearCache();
private:
void BuildGeometry(const FT_GlyphSlot glyph, GlyphGeometry &geo);
void RenderGeometry(const GlyphGeometry &geo);
void RenderOutline(const FT_GlyphSlot glyph);
FT_Library m_Library;
FT_Face m_Face;
FT_GlyphSlot m_Slot;
map<wchar_t,int> m_Cache;
#ifndef WIN32
#define __stdcall
#endif
static void __stdcall TessError(GLenum errCode, GlyphGeometry* geo);
static void __stdcall TessVertex(void* data, GlyphGeometry* geo);
static void __stdcall TessCombine(double coords[3], void* vertex_data[4], float weight[4], void** outData, GlyphGeometry* geo);
static void __stdcall TessBegin(GLenum type, GlyphGeometry* geo);
static void __stdcall TessEnd(GlyphGeometry* geo);
};
#endif