From: Mikko Rasa Date: Sat, 1 Nov 2014 00:26:34 +0000 (+0200) Subject: Remove separate element_buffer from Renderer, get it from mesh instead X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c46c75f8e3863dc3c6f91a2d5dc7f58333ec9260;p=libs%2Fgl.git Remove separate element_buffer from Renderer, get it from mesh instead --- diff --git a/source/mesh.cpp b/source/mesh.cpp index d1cb77f1..301c00f9 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -170,7 +170,6 @@ void Mesh::draw(Renderer &renderer) const } renderer.set_mesh(this); - renderer.set_element_buffer(ibuf); renderer.set_winding_test(winding); for(list::const_iterator i=batches.begin(); i!=batches.end(); ++i) diff --git a/source/renderer.cpp b/source/renderer.cpp index 2d262e73..bc49b0f8 100644 --- a/source/renderer.cpp +++ b/source/renderer.cpp @@ -26,8 +26,7 @@ Renderer::Renderer(const Camera *c): matrices_loaded(false), shdata_applied(0), camera(0), - state_stack(1), - element_buffer(0) + state_stack(1) { state_stack.reserve(16); shdata_stack.reserve(32); @@ -112,11 +111,6 @@ void Renderer::set_mesh(const Mesh *m) state->mesh = m; } -void Renderer::set_element_buffer(const Buffer *b) -{ - element_buffer = b; -} - void Renderer::set_winding_test(const WindingTest *w) { state->winding_test = w; @@ -203,10 +197,10 @@ void Renderer::draw(const Batch &batch) apply_state(); bool legacy_bindings = (!state->shprog || state->shprog->uses_legacy_variables()); - if(legacy_bindings) + if(state->mesh && legacy_bindings) { - if(element_buffer) - element_buffer->bind_to(ELEMENT_ARRAY_BUFFER); + if(const Buffer *ibuf = state->mesh->get_index_buffer()) + ibuf->bind_to(ELEMENT_ARRAY_BUFFER); else Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); } diff --git a/source/renderer.h b/source/renderer.h index 1f198dae..10d1fb3f 100644 --- a/source/renderer.h +++ b/source/renderer.h @@ -107,7 +107,6 @@ private: State *state; ProgramData standard_shdata; std::vector shdata_stack; - const Buffer *element_buffer; std::set excluded; public: @@ -140,7 +139,6 @@ public: void add_shader_data(const ProgramData &data); void set_mesh(const Mesh *); - void set_element_buffer(const Buffer *); void set_winding_test(const WindingTest *); void set_reverse_winding(bool);