AGX Dynamics  2.37.2.0
RenderText.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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
#define AGXOSG_EXPORT
Class for drawing simple/fast 2D text onto screen.
Definition: RenderText.h:38
unsigned int AGXOSG_EXPORT makeRasterFont(void)
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
void AGXOSG_EXPORT renderText(float x, float y, const char *s)
Render the bitmap text using previously created bitmap fonts.
TextDrawCallback * m_textDrawCallback
Definition: RenderText.h:72
void setPosition(const agx::Vec2 &pos)
Definition: RenderText.h:64
void drawImplementation(osg::RenderInfo &, const osg::Drawable *) const
Definition: RenderText.h:59
void setText(const std::string &text)
Definition: RenderText.h:65
virtual ~TextGeometry()
Definition: RenderText.h:52