X-Git-Url: http://git.tdb.fi/?p=netvis.git;a=blobdiff_plain;f=source%2Fhost.cpp;h=c18f117ba11d3dc360328ad0eb539c3d4e8939ed;hp=bd93de190a1e6217bf1f1d7d3b23e7ca7ad80632;hb=cc29ebb178d4695573f10a829534cb660e14e79d;hpb=6ffe2b950143c5474659cbca2bbcdf58d6b8322c diff --git a/source/host.cpp b/source/host.cpp index bd93de1..c18f117 100644 --- a/source/host.cpp +++ b/source/host.cpp @@ -24,7 +24,6 @@ Host::Host(NetVis &nv, unsigned a): addr(a), local(false), active(true), - activity(0), throttle(0) { in_addr ina; @@ -77,7 +76,7 @@ void Host::set_active(bool a) void Host::add_activity(unsigned bytes) { - activity += bytes*0.06935; + activity.add_bytes(bytes); } float Host::send_packet() @@ -92,7 +91,7 @@ void Host::tick(const Msp::Time::TimeDelta &td) { float dt = td/Msp::Time::sec; - activity *= pow(0.933f, dt); + activity.tick(td); throttle -= dt; if(throttle<0) throttle = 0; @@ -137,35 +136,23 @@ void Host::render() const if(!active) return; - GL::push_matrix(); + GL::PushMatrix push_; GL::translate(static_cast(pos.x), static_cast(pos.y), 0); - GL::Immediate imm((GL::COLOR4_UBYTE, GL::VERTEX2)); + GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); imm.begin(GL::QUADS); - imm.color(1.0f, 1.0f, 1.0f, max(min(static_cast(activity/10000), 1.0f), 0.2f)); + imm.color(1.0f, 1.0f, 1.0f, max(min(static_cast(activity.get_average()/10000), 1.0f), 0.2f)); imm.vertex(-5, -5); imm.vertex(5, -5); imm.vertex(5, 5); imm.vertex(-5, 5); imm.end(); - GL::pop_matrix(); -} - -void Host::render_label() const -{ - if(!active) - return; - const GL::Font &font = netvis.get_font(); - - GL::push_matrix(); - GL::translate(static_cast(pos.x)-static_cast(font.get_string_width(short_name)*5), static_cast(pos.y)+6, 0); + GL::translate(-static_cast(font.get_string_width(short_name)*5), 6, 0); GL::scale_uniform(10); - GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); imm.color(1.0f, 1.0f, 1.0f); font.draw_string(short_name, imm); - - GL::pop_matrix(); + GL::Texture::unbind(); }