[Plib-cvs] plib/src/fnt fntBitmap.cxx,NONE,1.1 Makefile.am,1.9,1.10 fnt.dsp,1.11,1.12 fnt.h,1.14,1.1
Brought to you by:
sjbaker
From: M?rten Str?m. <str...@us...> - 2004-02-15 19:58:55
|
Update of /cvsroot/plib/plib/src/fnt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8816 Modified Files: Makefile.am fnt.dsp fnt.h Added Files: fntBitmap.cxx Log Message: Added freeglut bitmap fonts. --- NEW FILE: fntBitmap.cxx --- /* PLIB - A Suite of Portable Game Libraries Copyright (C) 1998,2002 Steve Baker This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA For further information visit http://plib.sourceforge.net [...975 lines suppressed...] static fntBitmapFont fntHelvetica12 ARGS( fgFontHelvetica12 ); static fntBitmapFont fntHelvetica18 ARGS( fgFontHelvetica18 ); static fntBitmapFont fntTimesRoman10 ARGS( fgFontTimesRoman10 ); static fntBitmapFont fntTimesRoman24 ARGS( fgFontTimesRoman24 ); fntBitmapFont *fntGetBitmapFont(int id) { fntBitmapFont *fnt = NULL; switch (id) { case FNT_BITMAP_8_BY_13: fnt = &fntFixed8x13; break; case FNT_BITMAP_9_BY_15: fnt = &fntFixed9x15; break; case FNT_BITMAP_HELVETICA_10: fnt = &fntHelvetica10; break; case FNT_BITMAP_HELVETICA_12: fnt = &fntHelvetica12; break; case FNT_BITMAP_HELVETICA_18: fnt = &fntHelvetica18; break; case FNT_BITMAP_TIMES_ROMAN_10: fnt = &fntTimesRoman10; break; case FNT_BITMAP_TIMES_ROMAN_24: fnt = &fntTimesRoman24; break; } return fnt; } Index: Makefile.am =================================================================== RCS file: /cvsroot/plib/plib/src/fnt/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Makefile.am 31 Aug 2002 22:21:20 -0000 1.9 +++ Makefile.am 15 Feb 2004 19:51:23 -0000 1.10 @@ -4,7 +4,7 @@ include_HEADERS = fnt.h -libplibfnt_a_SOURCES = fnt.cxx fntTXF.cxx fntLocal.h +libplibfnt_a_SOURCES = fnt.cxx fntTXF.cxx fntLocal.h fntBitmap.cxx INCLUDES = -I$(top_srcdir)/src/sg -I$(top_srcdir)/src/util Index: fnt.dsp =================================================================== RCS file: /cvsroot/plib/plib/src/fnt/fnt.dsp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- fnt.dsp 17 Dec 2001 22:41:07 -0000 1.11 +++ fnt.dsp 15 Feb 2004 19:51:23 -0000 1.12 @@ -108,5 +108,9 @@ SOURCE=.\fntTXF.cxx # End Source File +# Begin Source File + +SOURCE=.\fntBitmap.cxx +# End Source File # End Target # End Project Index: fnt.h =================================================================== RCS file: /cvsroot/plib/plib/src/fnt/fnt.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- fnt.h 30 Nov 2002 00:41:49 -0000 1.14 +++ fnt.h 15 Feb 2004 19:51:23 -0000 1.15 @@ -214,7 +214,7 @@ vtx_left, vtx_right, vtx_bot, vtx_top ) ; } - int hasGlyph ( char c ) const { return exists[ c ] ; } + int hasGlyph ( char c ) const { return exists[ (GLubyte) c ] ; } void getBBox ( const char *s, float pointsize, float italic, float *left, float *right, @@ -244,6 +244,69 @@ } ; + +class fntBitmapFont : public fntFont +{ + protected: + + const GLubyte **data; + int first; + int count; + int height; + float xorig, yorig; + int fix; + float wid, gap; + + public: + + // data is a null-terminated list of glyph images: + // data[i][0] - image width + // data[i][1..n] - packed bitmap + + fntBitmapFont ( const GLubyte **data, int first, int height, + float xorig, float yorig ) ; + + virtual ~fntBitmapFont () ; + + virtual void getBBox ( const char *s, float pointsize, float italic, + float *left, float *right, + float *bot , float *top ) ; + + virtual void putch ( sgVec3 curpos, float pointsize, float italic, char c ) ; + virtual void puts ( sgVec3 curpos, float pointsize, float italic, const char *s ) ; + + virtual void begin () ; + virtual void end () ; + + virtual int load ( const char *fname, GLenum mag, GLenum min ) { return -1; } + + virtual void setFixedPitch ( int f ) { fix = f; } + virtual int isFixedPitch () const { return fix; } + + virtual void setWidth ( float w ) { wid = w; } + virtual void setGap ( float g ) { gap = g; } + + virtual float getWidth () const { return wid; } + virtual float getGap () const { return gap; } + + virtual int hasGlyph ( char c ) const ; +}; + + +/* Builtin Bitmap Fonts */ + +#define FNT_BITMAP_8_BY_13 0 +#define FNT_BITMAP_9_BY_15 1 +#define FNT_BITMAP_HELVETICA_10 2 +#define FNT_BITMAP_HELVETICA_12 3 +#define FNT_BITMAP_HELVETICA_18 4 +#define FNT_BITMAP_TIMES_ROMAN_10 5 +#define FNT_BITMAP_TIMES_ROMAN_24 6 + +fntBitmapFont *fntGetBitmapFont(int id); + + + class fntRenderer { fntFont *font ; |