X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ffont.cpp;h=5990c57d7223771410edadcfb69a9df13ea39fe0;hb=9be04243c92f024327e74ad8d48861581d83b7ed;hp=3fd24d8ea0ebde029e262d137dcfaf509b0db5ee;hpb=f89300d4264069e50a42c7e26b428957e750b437;p=libs%2Fgl.git diff --git a/source/font.cpp b/source/font.cpp index 3fd24d8e..5990c57d 100644 --- a/source/font.cpp +++ b/source/font.cpp @@ -3,8 +3,7 @@ #include "bindable.h" #include "gl.h" #include "font.h" -#include "immediate.h" -#include "primitivetype.h" +#include "primitivebuilder.h" #include "texture2d.h" using namespace std; @@ -64,17 +63,9 @@ float Font::get_string_width(const string &str, StringCodec::Decoder &dec) const return x; } -void Font::draw_string(const string &str, StringCodec::Decoder &dec, const Color &color) const -{ - BindRestore bind_tex(get_texture()); - Immediate imm((TEXCOORD2, COLOR4_UBYTE, VERTEX2)); - imm.color(color); - build_string(str, dec, imm); -} - void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveBuilder &bld) const { - MatrixStack::Push push_mtx(bld.matrix()); + VertexBuilder::PushMatrix push_mtx(bld); unsigned prev = 0; unsigned next = 0; @@ -94,7 +85,7 @@ void Font::build_string(const string &str, StringCodec::Decoder &dec, PrimitiveB continue; if(prev) - bld.matrix() *= Matrix::translation(get_glyph_advance(prev, c), 0, 0); + bld.transform(Matrix::translation(get_glyph_advance(prev, c), 0, 0)); create_glyph_quad(j->second, bld); prev = c; @@ -140,6 +131,20 @@ unsigned Font::get_ligature(unsigned code, unsigned next) const } +Font::Glyph::Glyph(): + code(0), + x1(0), + y1(0), + x2(1), + y2(1), + w(1), + h(1), + off_x(0), + off_y(0), + advance(1) +{ } + + Font::Loader::Loader(Font &f): DataFile::CollectionObjectLoader(f, 0) {