X-Git-Url: http://git.tdb.fi/?p=netvis.git;a=blobdiff_plain;f=source%2Fnetvis.cpp;h=e4d30579dac6e3352a38d9ccc69114c62d929649;hp=e9c6d50a3719da9628e935911a2c3f75b94b63df;hb=dca5eb6c41ea4315203fdf8edaa81e7f6575cca5;hpb=8814de48529f0b5b828372e471a7523b5f2bb6de diff --git a/source/netvis.cpp b/source/netvis.cpp index e9c6d50..e4d3057 100644 --- a/source/netvis.cpp +++ b/source/netvis.cpp @@ -5,7 +5,6 @@ Copyright @ 2008 Mikko Rasa, Mikkosoft Productions Distributed unter the GPL */ -#include #include #include #include @@ -34,6 +33,10 @@ using namespace std; using namespace Msp; NetVis::NetVis(int argc, char **argv): + pcap(0), + resolver(0), + wnd(0), + font(0), max_hosts(1000), max_visible_hosts(30), draw_labels(true), @@ -43,10 +46,7 @@ NetVis::NetVis(int argc, char **argv): if(argc<2) throw UsageError("No interface given"); iface = argv[1]; -} -int NetVis::main() -{ char err[1024]; pcap = pcap_open_live(iface.c_str(), 128, true, 0, err); if(!pcap) @@ -59,9 +59,9 @@ int NetVis::main() localnet = ntohl(localnet); localnet_mask = ntohl(localnet_mask); - dpy = new Graphics::Display; - wnd = new Graphics::Window(*dpy, 1024, 768); - glc = new Graphics::GLContext(*wnd); + resolver = new Resolver; + + wnd = new Graphics::SimpleGLWindow(1024, 768); wnd->set_title("NetVis"); wnd->signal_close.connect(sigc::bind(sigc::mem_fun(this, &NetVis::exit), 0)); wnd->signal_key_press.connect(sigc::mem_fun(this, &NetVis::key_press)); @@ -74,24 +74,14 @@ int NetVis::main() DataFile::load(*font, "dejavu-10.font"); catch_signal(SIGINT); +} - resolver = new Resolver; - - //set_loop_mode(TICK_BUSY); - - Application::main(); - +NetVis::~NetVis() +{ delete resolver; delete font; - delete glc; delete wnd; - delete dpy; - - cout<::iterator i=hosts.begin(); i!=hosts.end(); ++i) @@ -100,8 +90,6 @@ int NetVis::main() delete i->second; for(list::iterator i=packets.begin(); i!=packets.end(); ++i) delete *i; - - return exit_code; } void NetVis::tick() @@ -119,7 +107,7 @@ void NetVis::tick() frames = 0; } - dpy->tick(); + wnd->get_display().tick(); { Debug::ProfilingScope s(profiler, "capture"); @@ -269,7 +257,7 @@ void NetVis::tick() GL::pop_matrix(); GL::Texture::unbind(); - glc->swap_buffers(); + wnd->swap_buffers(); } ++frames;