dungeon_crawler

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