From 5791712b89bda9d70987592620c659b7b9f2435b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 13 Nov 2014 23:45:57 +0200 Subject: [PATCH] Use a shader for rendering if available --- source/root.cpp | 17 +++++++++++++++++ source/root.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/source/root.cpp b/source/root.cpp index f4bad55..8b06f47 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,4 +1,7 @@ #include +#include +#include +#include #include #include #include @@ -38,6 +41,18 @@ 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; + update_style(); if(mouse) @@ -57,6 +72,7 @@ void Root::init(Graphics::Window *window) Root::~Root() { + delete shprog; if(own_input) { delete keyboard; @@ -115,6 +131,7 @@ void Root::render() const GL::Bind bind_blend(GL::Blend::alpha()); GL::Renderer renderer(&camera); + renderer.set_shader_program(shprog); Widget::render(renderer); } diff --git a/source/root.h b/source/root.h index b79bca3..8e1bed9 100644 --- a/source/root.h +++ b/source/root.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -34,6 +35,7 @@ private: Time::TimeStamp tooltip_timeout; Widget *tooltip_target; Msp::GL::Camera camera; + Msp::GL::Program *shprog; public: /** Creates a Root widget for a window. The geometry is set to match the -- 2.43.0