]> git.tdb.fi Git - netvis.git/blobdiff - source/netvis.cpp
Adapt to MSP library changes
[netvis.git] / source / netvis.cpp
index 15b0cb51ecf4fcc86a80e42ba2d3324b887b9acf..52f586456f4a51b117b40e25ea482aa2980679f2 100644 (file)
@@ -13,7 +13,7 @@ Distributed unter the GPL
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
-#include <msp/core/except.h>
+#include <msp/core/getopt.h>
 #include <msp/debug/profilingscope.h>
 #include <msp/gl/blend.h>
 #include <msp/gl/framebuffer.h>
@@ -23,7 +23,7 @@ Distributed unter the GPL
 #include <msp/gl/projection.h>
 #include <msp/gl/texture2d.h>
 #include <msp/gl/transform.h>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include <msp/time/units.h>
 #include <msp/time/utils.h>
 #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<unsigned, Host *>::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<unsigned, Port *>::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> NetVis::reg;