dungeon_crawler

view prototype/drawtext/drawtext_impl.h @ 66:6a471c87f9ca

- added visual studio project files - changed some __func__ into __FUNCTION__ to compile on visual studio
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 07 Oct 2012 00:19:48 +0200
parents 2fc004802739
children
line source
1 /*
2 libdrawtext - a simple library for fast text rendering in OpenGL
3 Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef TEXT_IMPL_H_
19 #define TEXT_IMPL_H_
21 #include <stdio.h>
22 #include <string.h>
23 #include <errno.h>
25 struct glyph {
26 int code;
27 float x, y, width, height;
28 /* normalized coords [0, 1] */
29 float nx, ny, nwidth, nheight;
30 float orig_x, orig_y;
31 float advance;
32 struct glyph *next;
33 };
35 struct dtx_glyphmap {
36 int ptsize;
38 int xsz, ysz;
39 unsigned char *pixels;
40 unsigned int tex;
42 int cstart, cend; /* character range */
43 int crange;
45 float line_advance;
47 struct glyph *glyphs;
48 struct dtx_glyphmap *next;
49 };
51 struct dtx_font {
52 /* freetype FT_Face */
53 void *face;
55 /* list of glyphmaps */
56 struct dtx_glyphmap *gmaps;
58 /* last returned glyphmap (cache) */
59 struct dtx_glyphmap *last_gmap;
60 };
63 struct dtx_font *dtx_font;
64 int dtx_font_sz;
67 #define fperror(str) \
68 fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno))
70 int dtx_gl_init(void);
72 /* returns zero if it should NOT be printed and modifies xpos/ypos */
73 /* implemented in font.c */
74 struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
76 #endif /* TEXT_IMPL_H_ */