From 3a28abfa64d02b8d530689c425f6ed476a14fe9c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 29 Jul 2011 23:38:44 +0000 Subject: Render ui bitmaps through the materials system. --- src/ui/paint.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/ui/paint.cc') diff --git a/src/ui/paint.cc b/src/ui/paint.cc index 6531b0e..1745e1f 100644 --- a/src/ui/paint.cc +++ b/src/ui/paint.cc @@ -7,6 +7,7 @@ #include "auxiliary/functions.h" #include "math/vector2f.h" #include "render/gl.h" +#include "render/state.h" #include "render/text.h" #include "render/textures.h" #include "ui/paint.h" @@ -60,9 +61,20 @@ void Paint::draw_rectangle(const math::Vector2f &global_location, const math::Ve // draw a bitmap void Paint::draw_bitmap(const math::Vector2f &global_location, const math::Vector2f &size, const std::string &texture) { - render::Textures::bind(texture); - gl::enable(GL_TEXTURE_2D); - + // find the material + model::Material *material = model::Material::find(texture); + if (!material) { + material = new model::Material(texture); + model::Material::add(material); + material->set_texture(material->name()); + // ui btimaps are fullbright + material->set_flags(model::Material::Bright); + } + + render::State::set_color(math::Color()); + render::State::set_color_second(math::Color()); + render::State::use_material(material); + gl::begin(gl::Quads); glTexCoord2f(0.0f, 0.0f); @@ -79,7 +91,7 @@ void Paint::draw_bitmap(const math::Vector2f &global_location, const math::Vecto gl::end(); - gl::disable(GL_TEXTURE_2D); + render::State::reset(); } -- cgit v1.2.3