X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Frenderer.cpp;h=b935ce14c3e88bf94636135cc5ae0fe084574cbf;hb=9e63512930bc7dace6dc169c65161961e5dcfcf6;hp=19148a4dbf5a4f9bf1c9743481336ecf80297bb3;hpb=1fba50491957cdd28cff4082a32764691d8ec473;p=libs%2Fgl.git diff --git a/source/render/renderer.cpp b/source/render/renderer.cpp index 19148a4d..b935ce14 100644 --- a/source/render/renderer.cpp +++ b/source/render/renderer.cpp @@ -1,9 +1,8 @@ #include "batch.h" #include "buffer.h" #include "camera.h" -#include "clipping.h" -#include "deviceinfo.h" #include "error.h" +#include "framebuffer.h" #include "lighting.h" #include "material.h" #include "program.h" @@ -21,8 +20,7 @@ using namespace std; namespace Msp { namespace GL { -Renderer::Renderer(): - changed(0) +Renderer::Renderer() { state_stack.reserve(16); state_stack.push_back(State()); @@ -124,13 +122,6 @@ void Renderer::set_lighting(const Lighting *l) add_shader_data(l->get_shader_data()); } -void Renderer::set_clipping(const Clipping *c) -{ - state->clipping = c; - if(c) - add_shader_data(c->get_shader_data()); -} - void Renderer::set_shader_program(const Program *p, const ProgramData *d) { state->shprog = p; @@ -221,30 +212,15 @@ void Renderer::end() *state = State(); shdata_stack.clear(); add_shader_data(standard_shdata); - excluded.clear(); commands.use_pipeline(0); } -void Renderer::exclude(const Renderable &renderable) -{ - excluded.insert(&renderable); -} - -void Renderer::include(const Renderable &renderable) -{ - excluded.erase(&renderable); -} - -void Renderer::render(const Renderable &renderable, Tag tag) -{ - if(!excluded.count(&renderable)) - renderable.render(*this, tag); -} - void Renderer::clear(const ClearValue *values) { pipeline_state.set_framebuffer(state->framebuffer); + pipeline_state.set_viewport(state->viewport); + pipeline_state.set_scissor(state->scissor); commands.use_pipeline(&pipeline_state); commands.clear(values); } @@ -280,6 +256,16 @@ void Renderer::resolve_multisample(Framebuffer &target) commands.resolve_multisample(target); } +void Renderer::begin_query(const QueryPool &pool, unsigned index) +{ + commands.begin_query(pool, index); +} + +void Renderer::end_query(const QueryPool &pool, unsigned index) +{ + commands.end_query(pool, index); +} + void Renderer::apply_state() { if(!state->shprog) @@ -312,17 +298,18 @@ void Renderer::apply_state() pipeline_state.set_front_face(state->front_face); pipeline_state.set_face_cull(state->face_cull); - pipeline_state.set_enabled_clip_planes(state->clipping ? (1<clipping->get_n_planes())-1 : 0); if(state->texture_countshprog->get_uniform_binding(t.tag) : t.unit); - if(unit>=0) - pipeline_state.set_texture(unit, t.texture, t.sampler); - } + if(t.texture && t.replaced<0) + { + if(t.binding<0 || shprog_changed) + t.binding = state->shprog->get_uniform_binding(t.tag); + if(t.binding>=0) + pipeline_state.set_texture(t.binding, t.texture, t.sampler); + } bool shdata_changed = changed&SHADER_DATA; for(auto i=shdata_stack.begin(); (!shdata_changed && i!=shdata_stack.end()); ++i) @@ -347,36 +334,8 @@ void Renderer::apply_state() } -Renderer::BoundTexture::BoundTexture(): - unit(-1), - texture(0), - sampler(0), - replaced(-1) -{ } - - Renderer::BoundProgramData::BoundProgramData(const ProgramData *d): - shdata(d), - generation(0) -{ } - - -Renderer::State::State(): - camera(0), - framebuffer(0), - viewport(0), - scissor(0), - texture_count(0), - clipping(0), - shprog(0), - shdata_count(0), - vertex_setup(0), - front_face(NON_MANIFOLD), - face_cull(NO_CULL), - depth_test(0), - stencil_test(0), - blend(0), - object_lod_bias(0) + shdata(d) { } } // namespace GL