]> git.tdb.fi Git - netvis.git/commitdiff
Get rid of any direct gl* calls in favor of the mspgl wrappers
authorMikko Rasa <tdb@tdb.fi>
Thu, 22 Oct 2009 14:18:58 +0000 (14:18 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 22 Oct 2009 14:18:58 +0000 (14:18 +0000)
source/host.cpp
source/netvis.cpp

index 991e7741a04eb9a4acef1292992c707f08456b40..bd93de190a1e6217bf1f1d7d3b23e7ca7ad80632 100644 (file)
@@ -163,7 +163,9 @@ void Host::render_label() const
        GL::translate(static_cast<int>(pos.x)-static_cast<int>(font.get_string_width(short_name)*5), static_cast<int>(pos.y)+6, 0);
        GL::scale_uniform(10);
 
-       font.draw_string(short_name);
+       GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+       imm.color(1.0f, 1.0f, 1.0f);
+       font.draw_string(short_name, imm);
 
        GL::pop_matrix();
 }
index e4d30579dac6e3352a38d9ccc69114c62d929649..7f0ac9e6b5de33f0d9fec3ca86bd5721ebeab22f 100644 (file)
@@ -15,6 +15,8 @@ Distributed unter the GPL
 #include <linux/if_ether.h>
 #include <msp/core/except.h>
 #include <msp/debug/profilingscope.h>
+#include <msp/gl/blend.h>
+#include <msp/gl/framebuffer.h>
 #include <msp/gl/immediate.h>
 #include <msp/gl/matrix.h>
 #include <msp/gl/misc.h>
@@ -67,8 +69,8 @@ NetVis::NetVis(int argc, char **argv):
        wnd->signal_key_press.connect(sigc::mem_fun(this, &NetVis::key_press));
        wnd->show();
 
-       GL::enable(GL_BLEND);
-       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       GL::enable(GL::BLEND);
+       GL::blend_func(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA);
 
        font = new GL::Font;
        DataFile::load(*font, "dejavu-10.font");
@@ -184,7 +186,7 @@ void NetVis::tick()
 
        {
                Debug::ProfilingScope s(profiler, "render");
-               glClear(GL_COLOR_BUFFER_BIT);
+               GL::clear(GL::COLOR_BUFFER_BIT);
 
                GL::matrix_mode(GL::PROJECTION);
                GL::load_identity();
@@ -196,7 +198,6 @@ void NetVis::tick()
                        i->second->render();
                if(draw_labels)
                {
-                       glColor4f(1.0, 1.0, 1.0, 1.0);
                        for(map<unsigned, Host *>::iterator i=hosts.begin(); i!=hosts.end(); ++i)
                                i->second->render_label();
                        GL::Texture::unbind();
@@ -235,11 +236,12 @@ void NetVis::tick()
                        GL::push_matrix();
                        GL::translate(-484, 361, 0);
                        GL::scale_uniform(10);
-                       glColor4f(1.0, 1.0, 1.0, 1.0);
                        n = 0;
                        for(map<unsigned, GL::Color>::iterator i=port_colors.begin(); (i!=port_colors.end() && n<20); ++i, ++n)
                        {
-                               font->draw_string(format("%d", i->first));
+                               GL::Immediate imm2((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
+                               imm.color(1.0f, 1.0f, 1.0f);
+                               font->draw_string(format("%d", i->first), imm2);
 
                                GL::translate(0, -1.2, 0);
                        }