27 #elif defined(__FreeBSD__) 28 #include <machine/endian.h> 30 #define BIG_ENDIAN 1234 31 #define LITTLE_ENDIAN 4321 32 #define BYTE_ORDER LITTLE_ENDIAN 44 const char *
keySize[4] = {
"size big",
"size large",
"size medium",
"size small" };
48 #if BYTE_ORDER == BIG_ENDIAN 49 void swap32(
unsigned int *
p,
unsigned int size)
52 for (i = 0; i < size; i += 4) {
53 t = (
unsigned int) *
p;
54 *
p = (t & 0xff000000U) >> 24;
55 *
p |= (t & 0x00ff0000U) >> 8;
56 *
p |= (t & 0x0000ff00U) << 8;
57 *
p |= (t & 0x000000ffU) << 24;
70 const int BUFSIZE = 1024;
77 snprintf(buf, BUFSIZE,
"data/fonts/%s", fontName);
79 for(i = 0; i < 4; i++) {
86 snprintf(buf, BUFSIZE,
"data/fonts/%s", fontName);
88 for(i = 0; i < 4; i++) {
95 snprintf(buf, BUFSIZE,
"data/fonts/%s", fontName);
115 if ((Input = fopen(FileName,
"rb")) == NULL) {
125 fread(
font, 24, 1, Input);
128 #if BYTE_ORDER == BIG_ENDIAN 148 #if BYTE_ORDER == BIG_ENDIAN 157 if ((TexBytes = (
char *)malloc(Num)) == NULL) {
162 GfOut(
"font: %s, %d, %d, %d, %d, %d\n",
172 fread(TexBytes,
sizeof(
char), Num, Input);
177 glGenTextures(1, &Tex);
181 glBindTexture(GL_TEXTURE_2D, Tex);
182 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
183 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
184 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
186 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
187 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
190 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE_ALPHA,
font->
TexWidth,
191 font->
TexHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, TexBytes);
204 glDeleteTextures(1, &
font->
Tex);
233 Length = strlen(text);
236 for (i = 0; i < Length; i++) {
263 if (
font == NULL)
return 0;
274 if (
font == NULL)
return 0;
289 if (
font == NULL)
return;
292 Length = strlen(text);
295 glBindTexture(GL_TEXTURE_2D,
font->
Tex);
299 for (i = 0; i < Length; i++)
323 glTexCoord2f(Char->
tx1, Char->
ty1);
324 glVertex2f(x,
y + height);
325 glTexCoord2f(Char->
tx1, Char->
ty2);
327 glTexCoord2f(Char->
tx2, Char->
ty2);
328 glVertex2f(x + width,
y);
329 glTexCoord2f(Char->
tx2, Char->
ty1);
330 glVertex2f(x + width,
y + height);
void swap32(unsigned int *p, unsigned int size)
void output(int x, int y, const char *text)
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
#define GFPARM_RMODE_STD
if handle already openned return it
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
void create(int point_size)
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
The Gaming Framework API (client part).
GfuiFontClass * gfuiFont[FONT_NB]
Parameter header structure, a parameter can either carry a numeric or a string value, numeric value is constraint by min and max, string value by options in within.
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
GfuiFontClass(char *font)
int getWidth(const char *text)
#define GFPARM_RMODE_CREAT
Create the file if doesn't exist.