00001 // Filename: textGlyph.I 00002 // Created by: drose (08Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: TextGlyph::Default constructor 00022 // Access: Public 00023 // Description: This constructor makes an invalid glyph. 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE TextGlyph:: 00026 TextGlyph() { 00027 _geom = (Geom *)NULL; 00028 _advance = 0.0f; 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: TextGlyph::Constructor 00033 // Access: Public 00034 // Description: 00035 //////////////////////////////////////////////////////////////////// 00036 INLINE TextGlyph:: 00037 TextGlyph(Geom *geom, const RenderState *state, float advance) : 00038 _geom(geom), _state(state), _advance(advance) 00039 { 00040 if (_state == (RenderState *)NULL) { 00041 _state = RenderState::make_empty(); 00042 } 00043 } 00044 00045 //////////////////////////////////////////////////////////////////// 00046 // Function: TextGlyph::Copy Constructor 00047 // Access: Public 00048 // Description: 00049 //////////////////////////////////////////////////////////////////// 00050 INLINE TextGlyph:: 00051 TextGlyph(const TextGlyph ©) : 00052 _geom(copy._geom), 00053 _state(copy._state), 00054 _advance(copy._advance) 00055 { 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: TextGlyph::Copy Assignment Operator 00060 // Access: Public 00061 // Description: 00062 //////////////////////////////////////////////////////////////////// 00063 INLINE void TextGlyph:: 00064 operator = (const TextGlyph ©) { 00065 _geom = copy._geom; 00066 _state = copy._state; 00067 _advance = copy._advance; 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: TextGlyph::get_geom 00072 // Access: Public 00073 // Description: Returns a Geom that renders the particular glyph. 00074 //////////////////////////////////////////////////////////////////// 00075 INLINE PT(Geom) TextGlyph:: 00076 get_geom() const { 00077 if (_geom == (Geom *)NULL) { 00078 return _geom; 00079 } 00080 00081 // We always return a copy of the geom. That will allow the caller 00082 // to modify its vertices without fear of stomping on other copies; 00083 // it is also critical for the DynamicTextGlyph, which depends on 00084 // this behavior to properly count references to this glyph. 00085 return _geom->make_copy(); 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: TextGlyph::get_state 00090 // Access: Public 00091 // Description: Returns the state in which the glyph should be 00092 // rendered. 00093 //////////////////////////////////////////////////////////////////// 00094 INLINE const RenderState *TextGlyph:: 00095 get_state() const { 00096 return _state; 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: TextGlyph::get_advance 00101 // Access: Public 00102 // Description: Returns the distance by which the character pointer 00103 // should be advanced after placing this character; 00104 // i.e. the approximate width the character takes up on 00105 // the line. 00106 //////////////////////////////////////////////////////////////////// 00107 INLINE float TextGlyph:: 00108 get_advance() const { 00109 return _advance; 00110 }