X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=blobdiff_plain;f=source%2Froot.cpp;h=ef83bb9de3af842b8fe37878d1f4eb2185d36c12;hp=64c7dd5548fa2af424df645ac414860221dfc482;hb=6deafc9f236b90175a303944815f7c0eac1c95c1;hpb=999cd0294889e5eecd61df18a697d2c55ed6c0d6 diff --git a/source/root.cpp b/source/root.cpp index 64c7dd5..ef83bb9 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,12 +1,9 @@ #include -#include -#include -#include -#include #include #include #include "label.h" #include "style.h" +#include "resources.h" #include "root.h" #include "systemkeyboardinput.h" @@ -46,17 +43,11 @@ 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); @@ -83,7 +74,6 @@ void Root::init(Graphics::Window *window) Root::~Root() { - delete shprog; delete input_method; if(own_input) { @@ -144,23 +134,12 @@ void Root::tick() } } -void Root::render() -{ - rebuild_hierarchy(); - - GL::Bind bind_blend(GL::Blend::alpha()); - - GL::Renderer renderer(&camera); - renderer.set_shader_program(shprog); - Widget::render(renderer); -} - void Root::setup_frame(GL::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; @@ -168,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); }