X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Frenderer.cpp;h=d86b78046eb24454f954155f687d0c2ec9c710c0;hb=5b652353d545a3190ea2d86ba82a87b2e3382a0d;hp=1d43a939432f9a593381992824aedec7fca87f84;hpb=e24dcc10ff0d78203331eabae6b934c9e064105d;p=libs%2Fgl.git diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 1d43a939..d86b7804 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -12,7 +12,6 @@ #include "renderer.h" #include "sampler.h" #include "texture.h" -#include "texturing.h" #include "texunit.h" #include "vertexarray.h" #include "vertexsetup.h" @@ -23,22 +22,7 @@ using namespace std; namespace Msp { namespace GL { -Renderer::Renderer(): - default_camera(0) -{ - init(); -} - -Renderer::Renderer(const Camera *c): - default_camera(c) -{ - init(); - - if(c) - set_camera(*c); -} - -void Renderer::init() +Renderer::Renderer() { state_stack.reserve(16); state_stack.push_back(State()); @@ -72,16 +56,11 @@ void Renderer::transform(const Matrix &matrix) } void Renderer::set_texture(Tag tag, const Texture *tex, const Sampler *samp) -{ - set_texture(tag, -1, tex, samp); -} - -void Renderer::set_texture(Tag tag, int unit, const Texture *tex, const Sampler *samp) { if(texture_stack.size()>state->texture_count) { BoundTexture &bt = texture_stack[state->texture_count]; - if((!tag.id || bt.tag==tag) && (unit<0 || bt.unit==unit) && bt.texture==tex && bt.sampler==samp) + if(bt.tag==tag && bt.texture==tex && bt.sampler==samp) { ++state->texture_count; return; @@ -91,7 +70,7 @@ void Renderer::set_texture(Tag tag, int unit, const Texture *tex, const Sampler } for(vector::iterator i=texture_stack.end(); i!=texture_stack.begin(); ) - if((--i)->tag==tag && i->unit==unit) + if((--i)->tag==tag) { i->replaced = texture_stack.size(); break; @@ -100,17 +79,11 @@ void Renderer::set_texture(Tag tag, int unit, const Texture *tex, const Sampler texture_stack.push_back(BoundTexture()); BoundTexture &bound_tex = texture_stack.back(); bound_tex.tag = tag; - bound_tex.unit = unit; bound_tex.texture = tex; bound_tex.sampler = samp; state->texture_count = texture_stack.size(); } -void Renderer::set_texture(const Texture *t, const Sampler *s) -{ - set_texture(Tag(), 0, t, s); -} - void Renderer::flush_textures() { for(unsigned i=0; itexture_count, texture_stack.end()); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Renderer::set_texturing(const Texturing *t) -{ - if(t) - { - unsigned n_units = TexUnit::get_n_units(); - for(unsigned i=0; iget_attached_texture(i)) - set_texture(Tag(), i, tex, t->get_attached_sampler(i)); - } -} -#pragma GCC diagnostic pop - -unsigned Renderer::allocate_effect_texunit() -{ - return --state->lowest_effect_texunit; -} - void Renderer::set_material(const Material *m) { if(m) @@ -239,8 +193,6 @@ void Renderer::end() throw invalid_operation("Renderer::end"); *state = State(); - if(default_camera) - set_camera(*default_camera); shdata_stack.clear(); excluded.clear(); @@ -300,7 +252,7 @@ void Renderer::apply_state() for(vector::const_iterator i=texture_stack.begin(); i!=texture_stack.end(); ++i) { - int unit = (i->tag.id ? state->shprog->get_uniform_binding(i->tag) : i->unit); + int unit = state->shprog->get_uniform_binding(i->tag); if(unit>=0) { if(i->texture)