]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/text.h
Use default member initializers for simple types
[libs/gl.git] / source / render / text.h
index 40c9b8500097d1591f8be68b1ad6b3234870729b..c007c81f8aeaee0c9813dbf66915ccdd12814400 100644 (file)
@@ -4,16 +4,17 @@
 #include "font.h"
 #include "mesh.h"
 #include "object.h"
-#include "technique.h"
+#include "objectinstance.h"
 
 namespace Msp {
 namespace GL {
 
 /**
-Creates an object consisting of the visual representation of a string.  Can be
-used with an ObjectInstance to further customize the appearance.
+Creates an object consisting of the visual representation of a string.  If you
+derive from Text to customize it, make sure you call Text::setup_render or
+otherwise bind the appropriate texture.
 */
-class Text: public Renderable
+class Text: public ObjectInstance
 {
 public:
        enum HorizontalAlign
@@ -35,19 +36,20 @@ private:
        const Font &font;
        Mesh mesh;
        Object object;
-       Technique technique;
-       float horz_align;
-       float vert_offset;
-       float width;
+       Tag texture_slot;
+       float horz_align = 0.0f;
+       float vert_offset = 0.0f;
+       float width = 0.0f;
 
 public:
-       Text(const Font &, const Technique * = 0);
+       Text(const Font &, const Technique * = 0, Tag = Tag());
 
        const Mesh *get_mesh() const { return &mesh; }
 
-       /** Sets technique to render with.  It should have a texture slot named
-       "diffuse_map", which will be replaced with the font's texture. */
-       void set_technique(const Technique *);
+       /** Sets technique to render with, replacing the given texture slot with
+       the font texture.  If no texture slot is specified, heuristics are used to
+       choose a suitable one. */
+       void set_technique(const Technique *, Tag = Tag());
 
        const Technique *get_technique() const { return object.get_technique(); }
 
@@ -76,9 +78,9 @@ public:
 
        float get_width() const { return width; }
 
-       virtual void render(Renderer &, const Tag & = Tag()) const;
+       virtual void setup_render(Renderer &, Tag) const;
 
-       operator const Object &() const { return object; }
+       DEPRECATED operator const Object &() const { return object; }
 };
 
 } // namespace GL