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 #include <sys/types.h>
21 #include "SafeTexFont.hxx"
23 using namespace flightgear;
25 int SafeTexFont::load(const char *fname, GLenum mag, GLenum min)
28 if (stat(fname, &buf) == -1) {
38 bool SafeTexFont::ensureTextureLoaded()
40 if (_status != e_ERROR) {
41 if (_status == e_LOADED) {
44 int loadStatus = fntTexFont::load(_name.c_str(), _mag, _min);
45 if (loadStatus == FNT_TRUE) {
50 _error = ulGetError();
59 void SafeTexFont::begin()
61 if (ensureTextureLoaded())
65 void SafeTexFont::putch(sgVec3 curpos, float pointsize, float italic, char c)
67 if (ensureTextureLoaded())
68 fntTexFont::putch(curpos, pointsize, italic, c);
71 void SafeTexFont::puts(sgVec3 curpos, float pointsize, float italic,
74 if (ensureTextureLoaded())
75 fntTexFont::puts(curpos, pointsize, italic, s);