]> git.tdb.fi Git - netvis.git/blob - source/netvis.h
Get rid of the separate font texture
[netvis.git] / source / netvis.h
1 /* $Id$
2
3 This file is part of NetVis
4 Copyright @ 2008 Mikko Rasa, Mikkosoft Productions
5 Distributed unter the GPL
6 */
7
8 #ifndef NETVIS_H_
9 #define NETVIS_H_
10
11 #include <list>
12 #include <map>
13 #include <pcap.h>
14 #include <msp/core/application.h>
15 #include <msp/debug/profiler.h>
16 #include <msp/gbase/display.h>
17 #include <msp/gbase/glcontext.h>
18 #include <msp/gbase/window.h>
19 #include <msp/gl/color.h>
20 #include <msp/gl/font.h>
21 #include <msp/time/timestamp.h>
22
23 class Host;
24 class Packet;
25 class Resolver;
26
27 class NetVis: public Msp::Application
28 {
29 private:
30         std::string iface;
31         pcap_t *pcap;
32         std::list<Packet *> packets;
33         unsigned max_hosts;
34         unsigned max_visible_hosts;
35         std::map<unsigned, Host *> hosts;
36         std::map<unsigned, Host *> disabled_hosts;
37         Msp::Graphics::Display *dpy;
38         Msp::Graphics::Window *wnd;
39         Msp::Graphics::GLContext *glc;
40         Msp::Time::TimeStamp tick_t;
41         std::map<unsigned, Msp::GL::Color> port_colors;
42         Msp::GL::Font *font;
43         Msp::Debug::Profiler profiler;
44         bool draw_labels;
45         bool blend;
46         Resolver *resolver;
47         unsigned localnet;
48         unsigned localnet_mask;
49         Msp::Time::TimeStamp fps_t;
50         unsigned frames;
51         float fps;
52
53 public:
54         NetVis(int, char **);
55         int main();
56         const Msp::GL::Font &get_font() const { return *font; }
57         const std::map<unsigned, Host *> &get_hosts() const { return hosts; }
58 private:
59         virtual void tick();
60         Host &get_host(unsigned);
61         Msp::GL::Color &get_port_color(unsigned);
62         void key_press(unsigned, unsigned, wchar_t);
63
64         static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);
65
66         void sighandler(int);
67
68         static Application::RegApp<NetVis> reg;
69 };
70
71 #endif