AGXDynamics  2.35.0.3
RenderText.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXOSG_RENDERTEXT_H
18 #define AGXOSG_RENDERTEXT_H
19 
20 #include <agxOSG/export.h>
21 
22 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
23 #include <osg/Geometry>
24 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
25 
26 #include <agx/Vec2.h>
27 #include <string>
28 
29 namespace agxOSG {
30 
32  //void AGXOSG_EXPORT renderText(int x, int y, const char *s);
33  void AGXOSG_EXPORT renderText(float x, float y, const char *s);
34  unsigned int AGXOSG_EXPORT makeRasterFont(void);
35 
36 
38  class AGXOSG_EXPORT TextGeometry : public osg::Geometry
39  {
40  public:
41 
42  TextGeometry();
43 
45  void setPosition( const agx::Vec2& pos );
46 
48  void setText( const std::string& text );
49 
50  protected:
51 
52  virtual ~TextGeometry() {}
53 
54  class TextDrawCallback : public virtual osg::Drawable::DrawCallback
55  {
56  public:
58 
59  void drawImplementation(osg::RenderInfo& /*renderInfo*/,const osg::Drawable* /*drawable*/) const
60  {
61  agxOSG::renderText((float)m_pos[0], (float)m_pos[1] ,m_text.c_str());
62  }
63 
64  void setPosition( const agx::Vec2& pos ) { m_pos = pos; }
65  void setText( const std::string& text ) { m_text = text; }
66 
68  std::string m_text;
69  };
70 
71 
73  };
74 
75 }
76 
77 #endif
agxOSG::TextGeometry::~TextGeometry
virtual ~TextGeometry()
Definition: RenderText.h:52
agxOSG::TextGeometry::TextDrawCallback::m_text
std::string m_text
Definition: RenderText.h:68
agxOSG::TextGeometry
Class for drawing simple/fast 2D text onto screen.
Definition: RenderText.h:38
Vec2.h
agxOSG::TextGeometry::TextDrawCallback::setPosition
void setPosition(const agx::Vec2 &pos)
Definition: RenderText.h:64
agxOSG::TextGeometry::TextDrawCallback::m_pos
agx::Vec2 m_pos
Definition: RenderText.h:67
agxOSG
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
PushDisableWarnings.h
agxOSG::TextGeometry::TextDrawCallback::drawImplementation
void drawImplementation(osg::RenderInfo &, const osg::Drawable *) const
Definition: RenderText.h:59
agx::Vec2T
Definition: Vec2Template.h:30
agxOSG::renderText
void AGXOSG_EXPORT renderText(float x, float y, const char *s)
Render the bitmap text using previously created bitmap fonts.
agxOSG::TextGeometry::TextDrawCallback::TextDrawCallback
TextDrawCallback()
Definition: RenderText.h:57
agxOSG::TextGeometry::TextDrawCallback
Definition: RenderText.h:54
export.h
agxOSG::TextGeometry::TextDrawCallback::setText
void setText(const std::string &text)
Definition: RenderText.h:65
agxOSG::TextGeometry::m_textDrawCallback
TextDrawCallback * m_textDrawCallback
Definition: RenderText.h:72
agxOSG::makeRasterFont
unsigned int AGXOSG_EXPORT makeRasterFont(void)
AGXOSG_EXPORT
#define AGXOSG_EXPORT
PopDisableWarnings.h