X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetvis.cpp;h=52f586456f4a51b117b40e25ea482aa2980679f2;hb=d21b97e4f7f62ccdaf347012d6355a76f974f87e;hp=15b0cb51ecf4fcc86a80e42ba2d3324b887b9acf;hpb=7c86fe7860ade14b0387dec7ab564e6a480224b5;p=netvis.git diff --git a/source/netvis.cpp b/source/netvis.cpp index 15b0cb5..52f5864 100644 --- a/source/netvis.cpp +++ b/source/netvis.cpp @@ -13,7 +13,7 @@ Distributed unter the GPL #include #include #include -#include +#include #include #include #include @@ -23,7 +23,7 @@ Distributed unter the GPL #include #include #include -#include +#include #include #include #include "history.h" @@ -46,16 +46,16 @@ NetVis::NetVis(int argc, char **argv): frames(0) { if(argc<2) - throw UsageError("No interface given"); + throw usage_error("No interface given"); iface = argv[1]; char err[1024]; pcap = pcap_open_live(iface.c_str(), 128, true, 0, err); if(!pcap) - throw Exception(err); + throw runtime_error(err); if(pcap_setnonblock(pcap, true, err)==-1) - throw Exception(err); + throw runtime_error(err); pcap_lookupnet(iface.c_str(), &localnet, &localnet_mask, err); localnet = ntohl(localnet); @@ -68,8 +68,7 @@ NetVis::NetVis(int argc, char **argv): wnd->signal_close.connect(sigc::bind(sigc::mem_fun(this, &NetVis::exit), 0)); wnd->show(); - GL::enable(GL::BLEND); - GL::blend_func(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA); + GL::Blend::alpha().bind(); font = new GL::Font; DataFile::load(*font, "dejavu-10.font"); @@ -207,13 +206,10 @@ void NetVis::tick() void NetVis::render() { - GL::clear(GL::COLOR_BUFFER_BIT); + GL::Framebuffer::system().clear(GL::COLOR_BUFFER_BIT); - GL::matrix_mode(GL::PROJECTION); - GL::load_identity(); - GL::ortho_centered(1024, 768); - GL::matrix_mode(GL::MODELVIEW); - GL::load_identity(); + GL::MatrixStack::projection() = GL::Matrix::ortho_centered(1024, 768); + GL::MatrixStack::modelview() = GL::Matrix(); for(map::iterator i=hosts.begin(); i!=hosts.end(); ++i) i->second->render(); @@ -225,8 +221,7 @@ void NetVis::render() imm.end(); } - GL::push_matrix(); - GL::translate(-500, 360, 0); + GL::MatrixStack::modelview() = GL::Matrix::translation(-500, 360, 0); unsigned n = 0; for(map::iterator i=ports.begin(); (i!=ports.end() && n<50); ++i) { @@ -234,27 +229,22 @@ void NetVis::render() if((i->second->is_registered() && act>1) || act>200) { i->second->render(); - GL::translate(0, -12, 0); + GL::MatrixStack::modelview() *= GL::Matrix::translation(0, -12, 0); ++n; } } - GL::pop_matrix(); - GL::push_matrix(); - GL::translate(-500, -348, 0); - GL::scale_uniform(10); + GL::MatrixStack::modelview() = GL::Matrix::translation(-500, -348, 0); + GL::MatrixStack::modelview() *= GL::Matrix::scaling(10); font->draw_string(format("%d hosts", hosts.size()+disabled_hosts.size())); - GL::translate(0, -1.2, 0); + GL::MatrixStack::modelview() *= GL::Matrix::translation(0, -1.2, 0); font->draw_string(format("%d ports", ports.size())); - GL::translate(0, -1.2, 0); + GL::MatrixStack::modelview() *= GL::Matrix::translation(0, -1.2, 0); font->draw_string(format("%.2f fps", fps)); GL::Texture::unbind(); - GL::pop_matrix(); - GL::push_matrix(); - GL::translate(170, -370, 0); + GL::MatrixStack::modelview() = GL::Matrix::translation(170, -370, 0); history->render(); - GL::pop_matrix(); } Host &NetVis::get_host(unsigned a) @@ -364,5 +354,3 @@ void NetVis::sighandler(int) { exit(0); } - -Application::RegApp NetVis::reg;