X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmesh.cpp;h=45b022facc1edb8a673c4ea5e6d59485bff2b209;hb=55f24c84b7270e117615b212665f17d64771cede;hp=413986f463d60180d50f8b0d37982256e7c43ac5;hpb=8b99547d099c96bd8cc6037e2026db123b2523c1;p=libs%2Fgl.git diff --git a/source/mesh.cpp b/source/mesh.cpp index 413986f4..45b022fa 100644 --- a/source/mesh.cpp +++ b/source/mesh.cpp @@ -1,6 +1,7 @@ #include #include #include "buffer.h" +#include "error.h" #include "mesh.h" #include "renderer.h" @@ -75,6 +76,9 @@ void Mesh::create_buffers() void Mesh::refresh() const { + if(!vbuf) + return; + vertices.refresh(); if(dirty) { @@ -152,22 +156,19 @@ void Mesh::set_winding(const WindingTest *w) void Mesh::draw() const { + const Mesh *cur = current(); + if(cur && cur!=this) + throw invalid_operation("Mesh::draw"); + refresh(); if(!current()) - { vertices.apply(); - if(ibuf) - ibuf->bind_to(ELEMENT_ARRAY_BUFFER); - } - + Bind bind_ibuf(ibuf, ELEMENT_ARRAY_BUFFER); Bind bind_winding(winding); for(list::const_iterator i=batches.begin(); i!=batches.end(); ++i) i->draw(); - - if(!current() && ibuf) - Buffer::unbind_from(ELEMENT_ARRAY_BUFFER); } void Mesh::draw(Renderer &renderer) const