-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFontWriter.h
114 lines (96 loc) · 2.32 KB
/
FontWriter.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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef FONT_WRITER_H
#define FONT_WRITER_H
#include "stdafx.h"
// Simple bitmap font renderer
class FontWriter {
public:
FontWriter();
FontWriter(const char *fontname); // initialize the font writer with the specified font
~FontWriter()
{
DeleteFont();
}
virtual bool SetupFont();
virtual void DeleteFont();
virtual void PrintBitmapString(char* str,...); // prints a string and other arguments if necessary
void setRange(int rnge);
void setHeight(int hgt);
void fontRaster(int x, int y); // set the raster position for the text to be rendered
void setRaster(float xp, float yp);
void setPos(float xp, float yp, float zp);
void setPos(float p[3]);
void setColor(float r, float g, float b);
void setColor(float p[3]);
float *getRaster();
float *getPos();
protected:
char name[256]; // the name of the font
int fontlist; // the display list for the font
HFONT mFont; // handle to the font
int range;
int fontheight;
float position[3]; // the position to translate to to draw the font
float rasterPos[2]; // the raster position for this font
float color[3];
};
class FontWriter3d : public FontWriter {
public:
FontWriter3d()
{
depth = 0.5;
fontlist = 0;
name[0] = '\0';
mFont = NULL;
range = 256; // set the default character range set to 96
fontheight = 12;
color[0] = color[1] = color[2] = 1.0;
}
FontWriter3d(const char *fname)
{
depth = 0.5;
strcpy(name, fname);
fontlist = 0;
mFont = NULL;
range = 256; // set the default character range set to 96
fontheight = 12;
color[0] = color[1] = color[2] = 1.0;
}
~FontWriter3d()
{
DeleteFont();
}
virtual bool SetupFont();
void setDepth(float d);
GLYPHMETRICSFLOAT *getData();
virtual void PrintBitmapString(char* str,...);
protected:
float depth; // how thick are the fonts
GLYPHMETRICSFLOAT data[256];
};
class FontWriterTexture : public FontWriter
{
public:
FontWriterTexture()
{
name[0] = '\0';
textureId = -1;
textureImage = NULL;
}
FontWriterTexture(const char* texture)
{
strcpy(name, texture);
textureId = -1;
textureImage = NULL;
}
~FontWriterTexture()
{
DeleteFont();
}
virtual bool SetupFont();
virtual void DeleteFont();
virtual void PrintBitmapString(char* str,...); // prints a string and other arguments if necessary
protected:
unsigned int textureId;
corona::Image *textureImage;
};
#endif