X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhistory.cpp;h=19f6b34a9d3275662fb44f8c5b793e442966849e;hb=c1ea3cf06729622e2287e1604b1847d14fd2089c;hp=adcc3ec4042c2c48205ac63659343b6917f224f6;hpb=398c5e3e6e03080b6b057fd56858ab04694969ed;p=netvis.git diff --git a/source/history.cpp b/source/history.cpp index adcc3ec..19f6b34 100644 --- a/source/history.cpp +++ b/source/history.cpp @@ -5,11 +5,12 @@ Copyright @ 2008 Mikko Rasa, Mikkosoft Productions Distributed unter the GPL */ +#include #include #include #include #include -#include +#include #include #include "history.h" #include "netvis.h" @@ -25,18 +26,28 @@ History::History(NetVis &n, unsigned w, unsigned h): scale(1024), mesh((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)) { - texture.storage(GL::RGBA, height, width, 0); + unsigned texw = height; + unsigned texh = width; + if(!GL::is_supported("ARB_texture_non_power_of_two")) + { + for(texw=1; texw(height)/texw; + float hf = static_cast(width)/texh; GL::MeshBuilder bld(mesh); bld.color(1.0f, 1.0f, 1.0f); bld.begin(GL::QUADS); - bld.texcoord(0, 1); + bld.texcoord(0, hf); bld.vertex(0, 0); bld.texcoord(0, 0); bld.vertex(width, 0); - bld.texcoord(1, 0); + bld.texcoord(wf, 0); bld.vertex(width, height); - bld.texcoord(1, 1); + bld.texcoord(wf, hf); bld.vertex(0, height); bld.end(); } @@ -94,16 +105,14 @@ void History::render() const value /= 1024; suffix = 'M'; } - GL::PushMatrix push_; - GL::translate(width+5, height-10, 0); - GL::scale_uniform(10); - GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); - imm.color(1.0f, 1.0f, 1.0f); - netvis.get_font().draw_string(format("%d%c", value, suffix), imm); - GL::translate(0, (height-12)*-0.05, 0); - netvis.get_font().draw_string(format("%g%c", value*0.5, suffix), imm); - GL::translate(0, (height-12)*-0.05, 0); - netvis.get_font().draw_string(format("0%c", suffix), imm); + GL::MatrixStack::Push push_(GL::MatrixStack::modelview()); + GL::MatrixStack::modelview() *= GL::Matrix::translation(width+5, height-10, 0); + GL::MatrixStack::modelview() *= GL::Matrix::scaling(10); + netvis.get_font().draw_string(format("%d%c", value, suffix)); + GL::MatrixStack::modelview() *= GL::Matrix::translation(0, (height-12)*-0.05, 0); + netvis.get_font().draw_string(format("%g%c", value*0.5, suffix)); + GL::MatrixStack::modelview() *= GL::Matrix::translation(0, (height-12)*-0.05, 0); + netvis.get_font().draw_string(format("0%c", suffix)); GL::Texture::unbind(); } @@ -129,20 +138,20 @@ void History::create_texture() up_min = min(value+1, up_min); up_max = max(value, up_max); } - unsigned *row = &data[y*100]; - for(unsigned x=0; x<100; ++x) + unsigned *row = &data[y*height]; + for(unsigned x=0; x=up_min && x<=up_max) row[x] = 0xFF8000FF; else if(x<=down) row[x] = 0xFF80FF80; - else if(x%25==24 || y%60==0) + else if((x*4+4)%height==0 || y%60==0) row[x] = 0x40FFFFFF; else row[x] = 0x00000000; } } - texture.image(0, GL::RGBA, GL::UNSIGNED_BYTE, data.data()); + texture.sub_image(0, 0, 0, height, width, GL::RGBA, GL::UNSIGNED_BYTE, data.data()); }