AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
RenderText.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
29namespace 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
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
void setPosition(const agx::Vec2 &pos)
Definition RenderText.h:64
void setText(const std::string &text)
Definition RenderText.h:65
void drawImplementation(osg::RenderInfo &, const osg::Drawable *) const
Definition RenderText.h:59
Class for drawing simple/fast 2D text onto screen.
Definition RenderText.h:39
void setPosition(const agx::Vec2 &pos)
Set the position of the text.
TextDrawCallback * m_textDrawCallback
Definition RenderText.h:72
void setText(const std::string &text)
Set the text string.
virtual ~TextGeometry()
Definition RenderText.h:52
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
unsigned int AGXOSG_EXPORT makeRasterFont(void)
void AGXOSG_EXPORT renderText(float x, float y, const char *s)
Render the bitmap text using previously created bitmap fonts.