X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fimage.cpp;h=2735ab611e6a059e73faccae8aa079a0c47e8876;hb=319cde3c06181ba1c3619567525002926d8b4889;hp=3c0cfa53465a6f1befc6044c07a98652ed8a15bf;hpb=b92c878a286036af106e969a29b2689876aa5f65;p=libs%2Fgltk.git diff --git a/source/image.cpp b/source/image.cpp index 3c0cfa5..2735ab6 100644 --- a/source/image.cpp +++ b/source/image.cpp @@ -1,13 +1,4 @@ -/* $Id$ - -This file is part of libmspgltk -Copyright © 2010-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include -#include -#include +#include #include "image.h" #include "part.h" #include "style.h" @@ -45,20 +36,24 @@ void Image::autosize() geom.h = max(geom.h, margin.top+margin.bottom); } } + + rebuild(); } void Image::set_image(const GL::Texture2D *i) { image = i; signal_autosize_changed.emit(); + rebuild(); } void Image::set_keep_aspect(bool ka) { keep_aspect = ka; + rebuild(); } -void Image::render_special(const Part &part) const +void Image::rebuild_special(const Part &part) { if(part.get_name()=="image") { @@ -86,19 +81,18 @@ void Image::render_special(const Part &part) const } } - GL::Bind _bind_tex(image); - GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); - imm.color(1.0f, 1.0f, 1.0f); - imm.begin(GL::QUADS); - imm.texcoord(0.0, 0.0); - imm.vertex(rgeom.x, rgeom.y); - imm.texcoord(1.0, 0.0); - imm.vertex(rgeom.x+rgeom.w, rgeom.y); - imm.texcoord(1.0, 1.0); - imm.vertex(rgeom.x+rgeom.w, rgeom.y+rgeom.h); - imm.texcoord(0.0, 1.0); - imm.vertex(rgeom.x, rgeom.y+rgeom.h); - imm.end(); + GL::MeshBuilder bld(part_cache.create_mesh(part, *image)); + bld.color(1.0f, 1.0f, 1.0f); + bld.begin(GL::QUADS); + bld.texcoord(0.0, 0.0); + bld.vertex(rgeom.x, rgeom.y); + bld.texcoord(1.0, 0.0); + bld.vertex(rgeom.x+rgeom.w, rgeom.y); + bld.texcoord(1.0, 1.0); + bld.vertex(rgeom.x+rgeom.w, rgeom.y+rgeom.h); + bld.texcoord(0.0, 1.0); + bld.vertex(rgeom.x, rgeom.y+rgeom.h); + bld.end(); } }