X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Fclockwidget.cpp;h=5e00591e6bbc88b8d56b823622c8bcd1d70b85e4;hb=fa87851948ddc1908cfe6833aef08f582a7fb8fc;hp=31f5c3988a33a41954579d536fa651b2e65cbef6;hpb=f139a89c01dfc6580ecd1a5399e146ce45f865a4;p=r2c2.git diff --git a/source/engineer/clockwidget.cpp b/source/engineer/clockwidget.cpp index 31f5c39..5e00591 100644 --- a/source/engineer/clockwidget.cpp +++ b/source/engineer/clockwidget.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "clockwidget.h" @@ -8,32 +9,24 @@ using namespace Msp; ClockWidget::ClockWidget(R2C2::Clock &c): clock(c), - hour_hand((GL::VERTEX2, GL::COLOR4_UBYTE)), - minute_hand((GL::VERTEX2, GL::COLOR4_UBYTE)) + hour_hand((GL::VERTEX2, GL::TEXCOORD2, GL::COLOR4_UBYTE)), + minute_hand((GL::VERTEX2, GL::TEXCOORD2, GL::COLOR4_UBYTE)) { } -void ClockWidget::autosize_special(const GLtk::Part &, GLtk::Geometry &ageom) const -{ - ageom.w = max(ageom.w, 200U); - ageom.h = max(ageom.h, 200U); -} - void ClockWidget::rebuild_special(const GLtk::Part &part) { if(part.get_name()=="hourhand" || part.get_name()=="minutehand") { bool minute = (part.get_name()=="minutehand"); GL::Mesh &mesh = (minute ? minute_hand : hour_hand); - float length = min(geom.w, geom.h)*(minute ? 0.5f : 0.35f); - float width = length*(minute ? 0.05f : 0.1f); + + const GLtk::Graphic *graphic = part.get_graphic(state); + const GLtk::Alignment &align = part.get_alignment(); + mesh.clear(); GL::MeshBuilder bld(mesh); - bld.color(0.0f, 0.0f, 0.0f); - bld.begin(GL::TRIANGLES); - bld.vertex(width, -width); - bld.vertex(0.0f, length); - bld.vertex(-width, -width); - bld.end(); + bld.matrix() *= GL::Matrix::translation(GL::Vector3(graphic->get_width()*-align.x, graphic->get_height()*-align.y, 0)); + graphic->build(graphic->get_width(), graphic->get_height(), bld); part_cache.insert_special(part); } @@ -50,7 +43,6 @@ void ClockWidget::render_special(const GLtk::Part &part, GL::Renderer &renderer) Geometry::Angle angle = Geometry::Angle::from_turns(orientation); GL::Renderer::Push push(renderer); - renderer.set_texture(0); renderer.matrix_stack() *= GL::Matrix::translation(GL::Vector3(geom.w*0.5f, geom.h*0.5f, 0.0f)); renderer.matrix_stack() *= GL::Matrix::rotation(angle, GL::Vector3(0, 0, -1)); mesh.draw(renderer);