vrshoot

view libs/drawtext/drawtext_impl.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
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 struct glyph {
22 int code;
23 float x, y, width, height;
24 /* normalized coords [0, 1] */
25 float nx, ny, nwidth, nheight;
26 float orig_x, orig_y;
27 float advance;
28 struct glyph *next;
29 };
31 struct dtx_glyphmap {
32 int ptsize;
34 int xsz, ysz;
35 unsigned char *pixels;
36 unsigned int tex;
38 int cstart, cend; /* character range */
39 int crange;
41 float line_advance;
42 float baseline;
44 struct glyph *glyphs;
45 struct dtx_glyphmap *next;
46 };
48 struct dtx_font {
49 /* freetype FT_Face */
50 void *face;
52 /* list of glyphmaps */
53 struct dtx_glyphmap *gmaps;
55 /* last returned glyphmap (cache) */
56 struct dtx_glyphmap *last_gmap;
57 };
60 struct dtx_font *dtx_font;
61 int dtx_font_sz;
64 #define fperror(str) \
65 fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno))
67 int dtx_gl_init(void);
69 /* returns zero if it should NOT be printed and modifies xpos/ypos */
70 /* implemented in font.c */
71 struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
73 #endif /* TEXT_IMPL_H_ */