]> git.tdb.fi Git - libs/gltk.git/commitdiff
Bind the font texture in Text::render
authorMikko Rasa <tdb@tdb.fi>
Wed, 28 Nov 2012 18:29:04 +0000 (20:29 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 28 Nov 2012 18:29:04 +0000 (20:29 +0200)
source/text.cpp

index c6fe129fc405ab4c61aa34b3c088a784c9bf3f03..d80bd177126cbca14752ad65b262d3ac36bc340c 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/gl/immediate.h>
 #include <msp/gl/matrix.h>
+#include <msp/gl/texture2d.h>
 #include "style.h"
 #include "text.h"
 
@@ -160,6 +161,7 @@ void Text::render(const Part &part, const Geometry &parent, unsigned first_row)
        if(!style || lines.empty())
                return;
 
+       const GL::Font *font = style->get_font();
        const GL::Color &color = style->get_font_color();
        GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
        imm.color(color.r, color.g, color.b);
@@ -167,6 +169,8 @@ void Text::render(const Part &part, const Geometry &parent, unsigned first_row)
        RenderData data;
        data.bld = &imm;
 
+       GL::Bind bind_tex(font->get_texture());
+
        process_lines<RenderData, &Text::render_line>(part, parent, first_row, data);
 }
 
@@ -242,7 +246,7 @@ void Text::render_line(unsigned i, const Geometry &rgeom, RenderData &data) cons
        GL::translate(rgeom.x, rgeom.y, 0);
        GL::scale_uniform(font->get_default_size());
 
-       font->draw_string(text.substr(line.start, line.length), *data.bld);
+       font->build_string(text.substr(line.start, line.length), *data.bld);
 }
 
 void Text::coords_to_geom_line(unsigned i, const Geometry &rgeom, CoordsToGeomData &data) const