This eliminates a lot of texture and matrix thrashing.
}
}
-void Dropdown::render_special(const Part &part) const
+void Dropdown::render_special(const Part &part, GL::Renderer &renderer) const
{
if(part.get_name()=="list" && dropped)
- list.render();
+ list.render(renderer);
}
void Dropdown::button_press(int x, int y, unsigned btn)
private:
virtual void rebuild_special(const Part &, CachedPart &);
- virtual void render_special(const Part &) const;
+ virtual void render_special(const Part &, GL::Renderer &) const;
public:
virtual void button_press(int, int, unsigned);
}
}
-void Entry::render_special(const Part &part) const
+void Entry::render_special(const Part &part, GL::Renderer &renderer) const
{
if(part.get_name()=="slider" && multiline)
- slider->render();
+ slider->render(renderer);
}
void Entry::key_press(unsigned key, unsigned)
private:
virtual void rebuild_special(const Part &, CachedPart &);
- virtual void render_special(const Part &) const;
+ virtual void render_special(const Part &, GL::Renderer &) const;
public:
virtual void key_press(unsigned, unsigned);
}
}
-void List::render_special(const Part &part) const
+void List::render_special(const Part &part, GL::Renderer &renderer) const
{
if(part.get_name()=="slider")
- slider.render();
+ slider.render(renderer);
}
void List::button_press(int x, int y, unsigned btn)
private:
virtual void rebuild_special(const Part &, CachedPart &);
- virtual void render_special(const Part &) const;
+ virtual void render_special(const Part &, GL::Renderer &) const;
public:
virtual void button_press(int, int, unsigned);
return input_focus;
}
-void Panel::render_special(const Part &part) const
+void Panel::render_special(const Part &part, GL::Renderer &renderer) const
{
if(part.get_name()=="children")
{
for(list<Container::Child *>::const_iterator i=children.begin(); i!=children.end(); ++i)
if((*i)->widget->is_visible())
- (*i)->widget->render();
+ (*i)->widget->render(renderer);
}
}
Widget *get_final_input_focus() const;
protected:
- virtual void render_special(const Part &) const;
+ virtual void render_special(const Part &, GL::Renderer &) const;
public:
virtual void button_press(int, int, unsigned);
GL::MatrixStack::modelview() = GL::Matrix();
GL::Bind bind_blend(GL::Blend::alpha());
- Widget::render();
+ GL::Renderer renderer(0);
+ Widget::render(renderer);
}
void Root::button_press_event(unsigned btn)
}
}
-void Widget::render() const
+void Widget::render(GL::Renderer &renderer) const
{
if(!style)
throw logic_error(format("Attempt to render a widget with null style (class=\"%s\", style_name=\"%s\")", get_class(), style_name));
- GL::MatrixStack::Push _pushm(GL::MatrixStack::modelview());
- GL::MatrixStack::modelview() *= GL::Matrix::translation(geom.x, geom.y, 0);
+ GL::MatrixStack::Push _pushm(renderer.matrix_stack());
+ renderer.matrix_stack() *= GL::Matrix::translation(geom.x, geom.y, 0);
const Style::PartSeq &parts = style->get_parts();
list<CachedPart>::const_iterator j = cached_parts.begin();
for(Style::PartSeq::const_iterator i=parts.begin(); (i!=parts.end() && j!=cached_parts.end()); ++i, ++j)
{
if(j->mesh && j->texture)
{
- GL::Bind bind_tex(j->texture);
- j->mesh->draw();
+ renderer.set_texture(j->texture);
+ j->mesh->draw(renderer);
}
else if(!i->get_name().empty())
- render_special(*i);
+ render_special(*i, renderer);
}
}
#include <string>
#include <msp/datafile/objectloader.h>
+#include <msp/gl/renderer.h>
#include "geometry.h"
#include "partcache.h"
#include "state.h"
virtual void rebuild_special(const Part &, CachedPart &) { }
public:
- void render() const;
+ void render(GL::Renderer &) const;
protected:
- virtual void render_special(const Part &) const { }
+ virtual void render_special(const Part &, GL::Renderer &) const { }
public:
// Events