TextSprite.h
Go to the documentation of this file.
1 #ifndef B_TEXT_SPRITE_H
2 #define B_TEXT_SPRITE_H
3 
4 #include "Sprite.h"
5 #include "Configuration.h"
6 #include "Font.h"
7 
11 class TextSprite : public Sprite
12 {
13 public:
14 
15  /* Functions */
16 
25  TextSprite(ObjectManager *o, const std::string &name, vmml::Vector3f color, const std::string &text, FontPtr font, PropertiesPtr properties = nullptr);
26 
33  TextSprite(MaterialPtr material, const std::string &text, FontPtr font, PropertiesPtr properties = nullptr);
34 
38 
42  void setText(const std::string &text) { _text = text; createGeometry(); }
43 
46  std::string getText() { return _text; }
47 
51  void setFont(FontPtr font) { _font = font; createGeometry(); }
52 
55  FontPtr getFont() { return _font; }
56 
60  void setColor(const vmml::Vector3f &color) { getMaterial()->setVector(bRenderer::WAVEFRONT_MATERIAL_DIFFUSE_COLOR(), color); }
61 
62 private:
63 
64  /* Functions */
65  //void draw(GLenum mode, bool drawInstance, const std::string &instanceName);
66 
67  void createGeometry();
68 
69  /* Variables */
70 
71  FontPtr _font;
72  std::string _text;
73 };
74 
75 typedef std::shared_ptr< TextSprite > TextSpritePtr;
76 
77 #endif /* defined(B_TEXT_SPRITE_H) */
std::shared_ptr< Font > FontPtr
Definition: Font.h:84
virtual ~TextSprite()
Virtual destructor.
Definition: TextSprite.h:37
void setText(const std::string &text)
Set a text string.
Definition: TextSprite.h:42
std::shared_ptr< Properties > PropertiesPtr
Definition: Properties.h:179
FontPtr getFont()
Returns the font used to display the string.
Definition: TextSprite.h:55
void setFont(FontPtr font)
Set the font to be used to display the string.
Definition: TextSprite.h:51
A simple text sprite to display 2d text on the screen.
Definition: TextSprite.h:11
A 2d plane that can be rendered to the screen.
Definition: Sprite.h:9
virtual void deleteModelGeometry()
Deletes all geometry of the model.
Definition: Model.h:168
std::string WAVEFRONT_MATERIAL_DIFFUSE_COLOR()
Definition: Configuration.cpp:89
TextSprite(ObjectManager *o, const std::string &name, vmml::Vector3f color, const std::string &text, FontPtr font, PropertiesPtr properties=nullptr)
Constructor.
Definition: TextSprite.cpp:8
std::shared_ptr< TextSprite > TextSpritePtr
Definition: TextSprite.h:75
std::string getText()
Returns the text string of the sprite.
Definition: TextSprite.h:46
This class manages all objects in a project and makes sure no object is created twice.
Definition: ObjectManager.h:32
void setColor(const vmml::Vector3f &color)
Sets a color for the text.
Definition: TextSprite.h:60
MaterialPtr getMaterial()
Returns the material of the model.
Definition: Model.h:110
std::shared_ptr< Material > MaterialPtr
Definition: Material.h:135