AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
RenderText.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. 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#pragma once
18
19#include <agxOSG/export.h>
20
21#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
22#include <osg/Geometry>
23#include <agx/PopDisableWarnings.h> // End of disabled warnings.
24
25#include <agx/Vec2.h>
26#include <string>
27
28namespace agxOSG {
29
31 //void AGXOSG_EXPORT renderText(int x, int y, const char *s);
32 void AGXOSG_EXPORT renderText(float x, float y, const char *s);
33 unsigned int AGXOSG_EXPORT makeRasterFont(void);
34
35
37 class AGXOSG_EXPORT TextGeometry : public osg::Geometry
38 {
39 public:
40
42
44 void setPosition( const agx::Vec2& pos );
45
47 void setText( const std::string& text );
48
49 protected:
50
51 virtual ~TextGeometry() {}
52
53 class TextDrawCallback : public virtual osg::Drawable::DrawCallback
54 {
55 public:
57
58 void drawImplementation(osg::RenderInfo& /*renderInfo*/,const osg::Drawable* /*drawable*/) const
59 {
60 agxOSG::renderText((float)m_pos[0], (float)m_pos[1] ,m_text.c_str());
61 }
62
63 void setPosition( const agx::Vec2& pos ) { m_pos = pos; }
64 void setText( const std::string& text ) { m_text = text; }
65
67 std::string m_text;
68 };
69
70
72 };
73
74}
#define AGXOSG_EXPORT
void setPosition(const agx::Vec2 &pos)
Definition: RenderText.h:63
void setText(const std::string &text)
Definition: RenderText.h:64
void drawImplementation(osg::RenderInfo &, const osg::Drawable *) const
Definition: RenderText.h:58
Class for drawing simple/fast 2D text onto screen.
Definition: RenderText.h:38
void setPosition(const agx::Vec2 &pos)
Set the position of the text.
TextDrawCallback * m_textDrawCallback
Definition: RenderText.h:71
void setText(const std::string &text)
Set the text string.
virtual ~TextGeometry()
Definition: RenderText.h:51
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.