]> git.tdb.fi Git - netvis.git/blobdiff - source/netvis.h
Refactor the rendering code
[netvis.git] / source / netvis.h
index 9e8661e58307c43ed9efe5d289fcb1e9eaacde8a..3739d330ec941de08c03c2698a576269bcfa4b7a 100644 (file)
@@ -15,13 +15,14 @@ Distributed unter the GPL
 #include <msp/debug/profiler.h>
 #include <msp/gbase/display.h>
 #include <msp/gbase/glcontext.h>
-#include <msp/gbase/window.h>
+#include <msp/gbase/simplewindow.h>
 #include <msp/gl/color.h>
 #include <msp/gl/font.h>
 #include <msp/time/timestamp.h>
 
 class Host;
 class Packet;
+class Port;
 class Resolver;
 
 class NetVis: public Msp::Application
@@ -29,35 +30,40 @@ class NetVis: public Msp::Application
 private:
        std::string iface;
        pcap_t *pcap;
-       std::list<Packet *> packets;
+       Resolver *resolver;
+       unsigned localnet;
+       unsigned localnet_mask;
+
+       Msp::Graphics::SimpleGLWindow *wnd;
+       Msp::GL::Font *font;
+
+       unsigned max_hosts;
+       unsigned max_visible_hosts;
        std::map<unsigned, Host *> hosts;
        std::map<unsigned, Host *> disabled_hosts;
-       Msp::Graphics::Display *dpy;
-       Msp::Graphics::Window *wnd;
-       Msp::Graphics::GLContext *glc;
-       Msp::Time::TimeStamp tick_t;
-       std::map<unsigned, Msp::GL::Color> port_colors;
-       Msp::GL::Font *font;
-       Msp::GL::Texture2D *font_tex;
-       Msp::Debug::Profiler profiler;
+       std::list<Packet *> packets;
+       std::map<unsigned, Port *> ports;
        bool draw_labels;
        bool blend;
-       Resolver *resolver;
-       unsigned localnet;
-       unsigned localnet_mask;
+
+       Msp::Time::TimeStamp tick_t;
        Msp::Time::TimeStamp fps_t;
        unsigned frames;
        float fps;
 
 public:
        NetVis(int, char **);
-       int main();
+       ~NetVis();
+
        const Msp::GL::Font &get_font() const { return *font; }
        const std::map<unsigned, Host *> &get_hosts() const { return hosts; }
+       const std::map<unsigned, Port *> &get_ports() const { return ports; }
 private:
        virtual void tick();
+       void render();
        Host &get_host(unsigned);
-       Msp::GL::Color &get_port_color(unsigned);
+       Msp::GL::Color generate_color(bool) const;
+       const Port &get_port(unsigned);
        void key_press(unsigned, unsigned, wchar_t);
 
        static void capture_handler(unsigned char *, const pcap_pkthdr *, const unsigned char *);