Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGTextTXFGlyph.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #include "OSGTextTXFGlyph.h"
00040 
00041 
00042 OSG_BEGIN_NAMESPACE
00043 
00044 
00045 //----------------------------------------------------------------------
00046 // Constructor
00047 // Author: pdaehne
00048 //----------------------------------------------------------------------
00049 TextTXFGlyph::TextTXFGlyph()
00050 : TextGlyph(), _width(0), _height(0), _horiBearingX(0), _horiBearingY(0),
00051   _vertBearingX(0), _vertBearingY(0), _x(0), _y(0), _scale(1.f), _texCoord()
00052 {
00053     _texCoord[COORD_LEFT] = _texCoord[COORD_BOTTOM] =
00054     _texCoord[COORD_RIGHT] = _texCoord[COORD_TOP] = 0.f;
00055 }
00056 
00057 
00058 //----------------------------------------------------------------------
00059 // Destructor
00060 // Author: pdaehne
00061 //----------------------------------------------------------------------
00062 TextTXFGlyph::~TextTXFGlyph() {}
00063 
00064 
00065 //----------------------------------------------------------------------
00066 // Returns the width of the glyph
00067 // Author: pdaehne
00068 //----------------------------------------------------------------------
00069 Real32 TextTXFGlyph::getWidth() const
00070 { return static_cast<Real32>(_width) * _scale; }
00071 
00072 
00073 //----------------------------------------------------------------------
00074 // Returns the height of the glyph
00075 // Author: pdaehne
00076 //----------------------------------------------------------------------
00077 Real32 TextTXFGlyph::getHeight() const
00078 { return static_cast<Real32>(_height) * _scale; }
00079 
00080 
00081 //----------------------------------------------------------------------
00082 // Returns the x bearing of the glyph for horizontal layout
00083 // Author: pdaehne
00084 //----------------------------------------------------------------------
00085 Real32 TextTXFGlyph::getHoriBearingX() const
00086 { return static_cast<Real32>(_horiBearingX) * _scale; }
00087 
00088 
00089 //----------------------------------------------------------------------
00090 // Returns the y bearing of the glyph for horizontal layout
00091 // Author: pdaehne
00092 //----------------------------------------------------------------------
00093 Real32 TextTXFGlyph::getHoriBearingY() const
00094 { return static_cast<Real32>(_horiBearingY) * _scale; }
00095 
00096 
00097 //----------------------------------------------------------------------
00098 // Returns the x bearing of the glyph for vertical layout
00099 // Author: pdaehne
00100 //----------------------------------------------------------------------
00101 Real32 TextTXFGlyph::getVertBearingX() const
00102 { return static_cast<Real32>(_vertBearingX) * _scale; }
00103 
00104 
00105 //----------------------------------------------------------------------
00106 // Returns the y bearing of the glyph for vertical layout
00107 // Author: pdaehne
00108 //----------------------------------------------------------------------
00109 Real32 TextTXFGlyph::getVertBearingY() const
00110 { return static_cast<Real32>(_vertBearingY) * _scale; }
00111 
00112 
00113 //----------------------------------------------------------------------
00114 // Calculates coordinates
00115 // Author: pdaehne
00116 //----------------------------------------------------------------------
00117 void TextTXFGlyph::calculateCoordinates(UInt32 textureWidth,
00118                                             UInt32 textureHeight)
00119 {
00120     Real32 w = static_cast<Real32>(textureWidth);
00121     Real32 h = static_cast<Real32>(textureHeight);
00122     _texCoord[TextTXFGlyph::COORD_LEFT] = _x / w;
00123     _texCoord[TextTXFGlyph::COORD_BOTTOM] = _y / h;
00124     _texCoord[TextTXFGlyph::COORD_RIGHT] = (_x + _width) / w;
00125     _texCoord[TextTXFGlyph::COORD_TOP] = (_y + _height) / h;
00126 }
00127 
00128 
00129 OSG_END_NAMESPACE
00130 
00131 
00132 /*------------------------------------------------------------------------*/
00133 /*                              cvs id's                                  */
00134 
00135 #ifdef OSG_SGI_CC
00136 #pragma set woff 1174
00137 #endif
00138 
00139 #ifdef OSG_LINUX_ICC
00140 #pragma warning( disable : 177 )
00141 #endif
00142 
00143 namespace
00144 {
00145     static OSG::Char8 cvsid_cpp[] = "@(#)$Id: OSGTextTXFGlyph.cpp,v 1.1 2005/03/03 13:43:07 a-m-z Exp $";
00146     static OSG::Char8 cvsid_hpp[] = OSGTEXTTXFGLYPH_HEADER_CVSID;
00147     static OSG::Char8 cvsid_inl[] = OSGTEXTTXFGLYPH_INLINE_CVSID;
00148 }
00149 
00150 #ifdef __sgi
00151 #pragma reset woff 1174
00152 #endif

Generated on Thu Aug 25 04:11:18 2005 for OpenSG by  doxygen 1.4.3