OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Text3D.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGTEXT_TEXT3D
15 #define OSGTEXT_TEXT3D 1
16 
17 
18 #include <osgText/TextBase>
19 #include <osgText/Style>
20 
21 namespace osgText {
22 
23 
25 {
26  public:
27 
36  {
38  PER_GLYPH
39  };
40 
41  Text3D();
42  Text3D(const Text3D& text,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
43 
45 
46 
47  float getCharacterDepth() const;
48 
50  void setCharacterDepth(float characterDepth);
51 
53  RenderMode getRenderMode() const { return _renderMode; }
55  void setRenderMode(RenderMode renderMode) { _renderMode = renderMode; computeGlyphRepresentation(); }
56 
57 
59  osg::StateSet* getWallStateSet() { return _wallStateSet.get(); }
61  const osg::StateSet* getWallStateSet() const { return _wallStateSet.get(); }
64  {
65  if (_wallStateSet.valid() == false) _wallStateSet = new osg::StateSet;
66  return _wallStateSet.get();
67  }
69  void setWallStateSet(osg::StateSet* wallStateSet) { _wallStateSet = wallStateSet; }
70 
72  osg::StateSet* getBackStateSet() { return _backStateSet.get(); }
74  osg::StateSet* getBackStateSet() const { return _backStateSet.get(); }
76  osg::StateSet* getOrCreateBackStateSet() { if (_backStateSet.valid() == false) _backStateSet = new osg::StateSet; return _backStateSet.get(); }
78  void setBackStateSet(osg::StateSet* backStateSet) { _backStateSet = backStateSet; }
79 
80 
81 
83  virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
84 
86  virtual bool supports(const osg::Drawable::AttributeFunctor&) const { return false; }
87 
89  virtual bool supports(const osg::Drawable::ConstAttributeFunctor&) const { return false; }
90 
92  virtual void accept(osg::Drawable::ConstAttributeFunctor& af) const;
93 
95  virtual bool supports(const osg::PrimitiveFunctor&) const { return false; }
96 
98  virtual void accept(osg::PrimitiveFunctor& pf) const;
99 
100 
102  virtual void setThreadSafeRefUnref(bool threadSafe);
103 
105  virtual void resizeGLObjectBuffers(unsigned int maxSize);
106 
110  virtual void releaseGLObjects(osg::State* state=0) const;
111 
112  // // make Font a friend to allow it set the _font to 0 if the font is
113  // // forcefully unloaded.
114  friend class Font;
115 
116  virtual osg::BoundingBox computeBoundingBox() const;
117 
118 
119  protected:
120 
121  virtual ~Text3D() {}
122 
123  void renderPerGlyph(osg::State & state) const;
124  void renderPerFace(osg::State & state) const;
125 
126  String::iterator computeLastCharacterOnLine(osg::Vec2& cursor, String::iterator first,String::iterator last);
127 
128  void computeGlyphRepresentation();
129  void computePositions(unsigned int contextID) const;
130 
131  // ** glyph and other information to render the glyph
133  {
134  GlyphRenderInfo(GlyphGeometry* glyphGeometry, osg::Vec3 & pos):
135  _glyphGeometry(glyphGeometry),
136  _position(pos) {}
137 
140  };
141 
142  typedef std::vector<GlyphRenderInfo> LineRenderInfo;
143  typedef std::vector<LineRenderInfo> TextRenderInfo;
144 
145  TextRenderInfo _textRenderInfo;
146 
147 
149 
152 };
153 
154 }
155 
156 
157 #endif
void setBackStateSet(osg::StateSet *backStateSet)
Definition: Text3D.h:78
void setWallStateSet(osg::StateSet *wallStateSet)
Definition: Text3D.h:69
void setRenderMode(RenderMode renderMode)
Definition: Text3D.h:55
osg::StateSet * getOrCreateWallStateSet()
Definition: Text3D.h:63
osg::StateSet * getWallStateSet()
Definition: Text3D.h:59
#define META_Object(library, name)
Definition: Object.h:42
virtual bool supports(const osg::Drawable::ConstAttributeFunctor &) const
Definition: Text3D.h:89
osg::StateSet * getBackStateSet()
Definition: Text3D.h:72
std::vector< LineRenderInfo > TextRenderInfo
Definition: Text3D.h:143
RenderMode _renderMode
Definition: Text3D.h:148
TextRenderInfo _textRenderInfo
Definition: Text3D.h:145
GlyphRenderInfo(GlyphGeometry *glyphGeometry, osg::Vec3 &pos)
Definition: Text3D.h:134
osg::ref_ptr< GlyphGeometry > _glyphGeometry
Definition: Text3D.h:138
const osg::StateSet * getWallStateSet() const
Definition: Text3D.h:61
virtual ~Text3D()
Definition: Text3D.h:121
std::vector< GlyphRenderInfo > LineRenderInfo
Definition: Text3D.h:142
osg::ref_ptr< osg::StateSet > _wallStateSet
Definition: Text3D.h:150
virtual bool supports(const osg::Drawable::AttributeFunctor &) const
Definition: Text3D.h:86
osg::ref_ptr< osg::StateSet > _backStateSet
Definition: Text3D.h:151
osg::StateSet * getBackStateSet() const
Definition: Text3D.h:74
osg::StateSet * getOrCreateBackStateSet()
Definition: Text3D.h:76
#define OSGTEXT_EXPORT
Definition: Export.h:39
virtual bool supports(const osg::PrimitiveFunctor &) const
Definition: Text3D.h:95