#include <msp/gl/extensions/arb_vertex_array_object.h>
#include <msp/gl/extensions/arb_vertex_shader.h>
#include "buffer.h"
+#include "error.h"
#include "mesh.h"
#include "renderer.h"
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<Batch>::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