X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Froot.cpp;h=ef83bb9de3af842b8fe37878d1f4eb2185d36c12;hb=70e7a223a069874cda84673a4ca541aa44b12bf2;hp=b31b53f2d7e2f767cd48fb253eef5e436afdb863;hpb=aa939035cbb1bc2b89f77255953b2927690e4cca;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index b31b53f..ef83bb9 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,13 +1,9 @@ #include -#include -#include -#include -#include #include -#include #include #include "label.h" #include "style.h" +#include "resources.h" #include "root.h" #include "systemkeyboardinput.h" @@ -47,17 +43,14 @@ void Root::init(Graphics::Window *window) camera.set_orthographic(geom.w, geom.h); update_camera(); - if(GL::ARB_shader_objects) - { - shprog = new GL::Program; - GL::ProgramBuilder::StandardFeatures features; - features.material = true; - features.texture = true; - GL::ProgramBuilder(features).add_shaders(*shprog); - shprog->link(); - } - else - shprog = 0; + shprog = &resources.get("ui.shader"); + + blend.enabled = true; + blend.src_factor = GL::SRC_ALPHA; + blend.dst_factor = GL::ONE_MINUS_SRC_ALPHA; + + if(keyboard) + set_state(FOCUS); update_style(); @@ -81,7 +74,6 @@ void Root::init(Graphics::Window *window) Root::~Root() { - delete shprog; delete input_method; if(own_input) { @@ -92,6 +84,12 @@ Root::~Root() void Root::tick() { + Time::TimeStamp t = Time::now(); + Time::TimeDelta dt = (last_tick ? t-last_tick : Time::zero); + last_tick = t; + + animate(dt); + if(tooltip_timeout && Time::now()>tooltip_timeout) { std::string tip; @@ -136,16 +134,12 @@ void Root::tick() } } -void Root::render() const +void Root::setup_frame(GL::Renderer &) { - GL::Bind bind_blend(GL::Blend::alpha()); - - GL::Renderer renderer(&camera); - renderer.set_shader_program(shprog); - Widget::render(renderer); + rebuild_hierarchy(); } -void Root::render(GL::Renderer &renderer, const GL::Tag &tag) const +void Root::render(GL::Renderer &renderer, GL::Tag tag) const { if(tag.id) return; @@ -153,8 +147,8 @@ void Root::render(GL::Renderer &renderer, const GL::Tag &tag) const GL::Renderer::Push push(renderer); renderer.set_camera(camera); renderer.set_shader_program(shprog); - GL::BindRestore bind_blend(GL::Blend::alpha()); - GL::BindRestore unbind_dtest(static_cast(0)); + renderer.set_blend(&blend); + renderer.set_depth_test(0); Widget::render(renderer); } @@ -289,9 +283,9 @@ void Root::update_camera() camera.set_orthographic(geom.w, geom.h); } -void Root::on_geometry_change() +void Root::on_size_change() { - Panel::on_geometry_change(); + Panel::on_size_change(); update_camera(); }