vrshoot

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/drawtext/drawtext_impl.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,73 @@
     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 +	float baseline;
    1.46 +
    1.47 +	struct glyph *glyphs;
    1.48 +	struct dtx_glyphmap *next;
    1.49 +};
    1.50 +
    1.51 +struct dtx_font {
    1.52 +	/* freetype FT_Face */
    1.53 +	void *face;
    1.54 +
    1.55 +	/* list of glyphmaps */
    1.56 +	struct dtx_glyphmap *gmaps;
    1.57 +
    1.58 +	/* last returned glyphmap (cache) */
    1.59 +	struct dtx_glyphmap *last_gmap;
    1.60 +};
    1.61 +
    1.62 +
    1.63 +struct dtx_font *dtx_font;
    1.64 +int dtx_font_sz;
    1.65 +
    1.66 +
    1.67 +#define fperror(str) \
    1.68 +	fprintf(stderr, "%s: %s: %s\n", __FUNCTION__, (str), strerror(errno))
    1.69 +
    1.70 +int dtx_gl_init(void);
    1.71 +
    1.72 +/* returns zero if it should NOT be printed and modifies xpos/ypos */
    1.73 +/* implemented in font.c */
    1.74 +struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
    1.75 +
    1.76 +#endif	/* TEXT_IMPL_H_ */