dungeon_crawler

annotate prototype/drawtext/drawtext_impl.h @ 24:e122ba214ee1

implementing the command console
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Aug 2012 18:03:11 +0300
parents
children 2fc004802739
rev   line source
nuclear@24 1 /*
nuclear@24 2 libdrawtext - a simple library for fast text rendering in OpenGL
nuclear@24 3 Copyright (C) 2011 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@24 21 struct glyph {
nuclear@24 22 int code;
nuclear@24 23 float x, y, width, height;
nuclear@24 24 /* normalized coords [0, 1] */
nuclear@24 25 float nx, ny, nwidth, nheight;
nuclear@24 26 float orig_x, orig_y;
nuclear@24 27 float advance;
nuclear@24 28 struct glyph *next;
nuclear@24 29 };
nuclear@24 30
nuclear@24 31 struct dtx_glyphmap {
nuclear@24 32 int ptsize;
nuclear@24 33
nuclear@24 34 int xsz, ysz;
nuclear@24 35 unsigned char *pixels;
nuclear@24 36 unsigned int tex;
nuclear@24 37
nuclear@24 38 int cstart, cend; /* character range */
nuclear@24 39 int crange;
nuclear@24 40
nuclear@24 41 float line_advance;
nuclear@24 42
nuclear@24 43 struct glyph *glyphs;
nuclear@24 44 struct dtx_glyphmap *next;
nuclear@24 45 };
nuclear@24 46
nuclear@24 47 struct dtx_font {
nuclear@24 48 /* freetype FT_Face */
nuclear@24 49 void *face;
nuclear@24 50
nuclear@24 51 /* list of glyphmaps */
nuclear@24 52 struct dtx_glyphmap *gmaps;
nuclear@24 53
nuclear@24 54 /* last returned glyphmap (cache) */
nuclear@24 55 struct dtx_glyphmap *last_gmap;
nuclear@24 56 };
nuclear@24 57
nuclear@24 58
nuclear@24 59 struct dtx_font *dtx_font;
nuclear@24 60 int dtx_font_sz;
nuclear@24 61
nuclear@24 62
nuclear@24 63 #define fperror(str) \
nuclear@24 64 fprintf(stderr, "%s: %s: %s\n", __func__, (str), strerror(errno))
nuclear@24 65
nuclear@24 66 int dtx_gl_init(void);
nuclear@24 67
nuclear@24 68 /* returns zero if it should NOT be printed and modifies xpos/ypos */
nuclear@24 69 /* implemented in font.c */
nuclear@24 70 struct dtx_glyphmap *dtx_proc_char(int code, float *xpos, float *ypos);
nuclear@24 71
nuclear@24 72 #endif /* TEXT_IMPL_H_ */