1 // Copyright (C) 2008 Tim Moore
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #ifndef FLIGHTGEAR_SAFETEXFONT_HXX
18 #define FLIGHTGEAR_SAFETEXFONT_HXX 1
27 * Subclass of plib's fntTexFont that defers the loading of the font
28 * texture until just before rendering, insuring that it happens in
29 * the proper graphics context.
31 class SafeTexFont : public fntTexFont
34 SafeTexFont() : _status(e_NOT_LOADED) {}
35 /** Load the texture for this font.
36 * @param mag OpenGL texture magnification; default is GL_NEAREST
37 * @param min OpenGL texture minification; default is
38 * GL_LINEAR_MIPMAP_LINEAR.
39 * @return the plib value FNT_FALSE if the font file doesn't
40 * exist; otherwise returns FNT_TRUE.
42 int load(const char *fname, GLenum mag = GL_NEAREST,
43 GLenum min = GL_LINEAR_MIPMAP_LINEAR);
45 void putch(sgVec3 curpos, float pointsize, float italic, char c);
46 void puts(sgVec3 curpos, float pointsize, float italic, const char *s);
53 FontStatus getStatus() { return _status; }
54 std::string& fntError() { return _error; }
56 bool ensureTextureLoaded();