3dphotoshoot
diff libs/drawtext/drawtext_impl.h @ 10:c71c477521ca
converting to GLES2 and C++
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 31 May 2015 00:40:26 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/drawtext/drawtext_impl.h Sun May 31 00:40:26 2015 +0300 1.3 @@ -0,0 +1,72 @@ 1.4 +/* 1.5 +libdrawtext - a simple library for fast text rendering in OpenGL 1.6 +Copyright (C) 2011-2012 John Tsiombikas <nuclear@member.fsf.org> 1.7 + 1.8 +This program is free software: you can redistribute it and/or modify 1.9 +it under the terms of the GNU Lesser General Public License as published by 1.10 +the Free Software Foundation, either version 3 of the License, or 1.11 +(at your option) any later version. 1.12 + 1.13 +This program is distributed in the hope that it will be useful, 1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of 1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.16 +GNU Lesser General Public License for more details. 1.17 + 1.18 +You should have received a copy of the GNU Lesser General Public License 1.19 +along with this program. If not, see <http://www.gnu.org/licenses/>. 1.20 +*/ 1.21 +#ifndef TEXT_IMPL_H_ 1.22 +#define TEXT_IMPL_H_ 1.23 + 1.24 +struct glyph { 1.25 + int code; 1.26 + float x, y, width, height; 1.27 + /* normalized coords [0, 1] */ 1.28 + float nx, ny, nwidth, nheight; 1.29 + float orig_x, orig_y; 1.30 + float advance; 1.31 + struct glyph *next; 1.32 +}; 1.33 + 1.34 +struct dtx_glyphmap { 1.35 + int ptsize; 1.36 + 1.37 + int xsz, ysz; 1.38 + unsigned char *pixels; 1.39 + unsigned int tex; 1.40 + 1.41 + int cstart, cend; /* character range */ 1.42 + int crange; 1.43 + 1.44 + float line_advance; 1.45 + 1.46 + struct glyph *glyphs; 1.47 + struct dtx_glyphmap *next; 1.48 +}; 1.49 + 1.50 +struct dtx_font { 1.51 + /* freetype FT_Face */ 1.52 + void *face; 1.53 + 1.54 + /* list of glyphmaps */ 1.55 + struct dtx_glyphmap *gmaps; 1.56 + 1.57 + /* last returned glyphmap (cache) */ 1.58 + struct dtx_glyphmap *last_gmap; 1.59 +}; 1.60 + 1.61 + 1.62 +struct dtx_font *dtx_font; 1.63 +int dtx_font_sz; 1.64 + 1.65 + 1.66 +#define fperror(str) \ 1.67 + fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno)) 1.68 + 1.69 +int dtx_gl_init(void); 1.70 + 1.71 +/* returns zero if it should NOT be printed and modifies xpos/ypos */ 1.72 +/* implemented in font.c */ 1.73 +struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos); 1.74 + 1.75 +#endif /* TEXT_IMPL_H_ */