- BindRestore _bind(*this);
- Buffer::unbind_from(ARRAY_BUFFER);
-
- unsigned mask = get_attribs(vertex_format)|get_attribs(inst_format);
- for(unsigned i=0; mask; ++i, mask>>=1)
- if(mask&1)
- {
- glDisableVertexAttribArray(i);
- glVertexAttribPointer(i, 1, GL_FLOAT, false, 0, 0);
- }
- glBindBuffer(ELEMENT_ARRAY_BUFFER, 0);
+ glBindVertexArray(id);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ for(const unsigned char *a=vertex_format.begin(); a!=vertex_format.end(); ++a)
+ {
+ unsigned sem = get_attribute_semantic(*a);
+ glDisableVertexAttribArray(sem);
+ glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0);
+ }
+ for(const unsigned char *a=inst_format.begin(); a!=inst_format.end(); ++a)
+ {
+ unsigned sem = get_attribute_semantic(*a);
+ glDisableVertexAttribArray(sem);
+ glVertexAttribPointer(sem, 1, GL_FLOAT, false, 0, 0);
+ }
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);