From: Mikko Rasa Date: Sun, 28 Jul 2019 00:03:58 +0000 (+0300) Subject: Add a function to flush shader data in Renderer X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=afb95d09c066b45b7a66b644c04e2d0b2cee2723;p=libs%2Fgl.git Add a function to flush shader data in Renderer Necessary if the same shader data object is used in successive draw commands but the contained uniform values are changed. --- diff --git a/source/renderer.cpp b/source/renderer.cpp index 90ac4551..c5fe3c64 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -134,14 +134,19 @@ void Renderer::add_shader_data(const ProgramData &d) ++state->shdata_count; else { - if(shdata_stack.size()>state->shdata_count) - shdata_stack.erase(shdata_stack.begin()+state->shdata_count, shdata_stack.end()); + flush_shader_data(); shdata_stack.push_back(&d); state->shdata_count = shdata_stack.size(); changed |= SHADER_DATA; } } +void Renderer::flush_shader_data() +{ + if(shdata_stack.size()>state->shdata_count) + shdata_stack.erase(shdata_stack.begin()+state->shdata_count, shdata_stack.end()); +} + void Renderer::set_mesh(const Mesh *m) { state->mesh = m; diff --git a/source/renderer.h b/source/renderer.h index 973e1b00..f997171c 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -151,6 +151,8 @@ public: Renderer state is popped. */ void add_shader_data(const ProgramData &data); + void flush_shader_data(); + void set_mesh(const Mesh *); void set_vertex_setup(const VertexSetup *); void set_winding_test(const WindingTest *);