X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Ftext.h;h=b4fc8f52e9aae3ddc2aae3344dce51b3e567804e;hb=9e63512930bc7dace6dc169c65161961e5dcfcf6;hp=0b4fa92c4ac5fe0197dbc917f19bb6453eded733;hpb=5bb193f930fb8738d099d630c4d625d82c1215b5;p=libs%2Fgl.git diff --git a/source/render/text.h b/source/render/text.h index 0b4fa92c..b4fc8f52 100644 --- a/source/render/text.h +++ b/source/render/text.h @@ -10,9 +10,13 @@ namespace Msp { namespace GL { /** -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. +Creates a Mesh and an Object for rendering text. + +The mesh is created with a font size of 1 unit. Set the Text's model matrix to +scale it to the desired size. + +If you derive from Text to customize it, make sure you call Text::setup_render +or otherwise set the appropriate texture to the Renderer. */ class Text: public ObjectInstance { @@ -37,23 +41,23 @@ private: Mesh mesh; Object object; Tag texture_slot; - float horz_align; - float vert_offset; - float width; + float horz_align = 0.0f; + float vert_offset = 0.0f; + float width = 0.0f; public: Text(const Font &, const Technique * = 0, Tag = Tag()); const Mesh *get_mesh() const { return &mesh; } - /** Sets technique to render with, replacing the given texture slot with + /** Sets technique to render with, along with the texture slot to use for 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(); } - /// Sets the string to be displayed. + /** Sets the string to be displayed, with an explicit character encoding. */ void set_text(const std::string &, StringCodec::Decoder &); template @@ -63,13 +67,14 @@ public: set_text(t, dec); } + /** Sets the string to be displayed, with UTF-8 encoding. */ void set_text(const std::string &t) { set_text(t); } - /// Clears the object's contents. + /** Clears any previous contents. */ void clear(); - /// Sets horizontal and vertical alignment with predefined anchors. + /** Sets horizontal and vertical alignment with predefined anchors. */ void set_alignment(HorizontalAlign, VerticalAlign = BASELINE); /** Sets horizontal and vertical alignment. 0.0 means left or baseline,