26VertexArray::remove_vbo (std::string
const& name)
28 VBOList::iterator new_end = std::remove_if(this->vbo_list.begin(),
29 this->vbo_list.end(), VBORemovePred(name));
30 this->vbo_list.erase(new_end, this->vbo_list.end());
36VertexArray::assign_attrib (
BoundVBO const& bound_vbo)
39 std::string
const& name = bound_vbo.second;
41 GLint location = this->shader->get_attrib_location(name.c_str());
46 glVertexAttribPointer(location, vbo->get_values_per_vertex(),
47 vbo->get_data_type(), GL_TRUE, 0,
nullptr);
49 glEnableVertexAttribArray(location);
56VertexArray::draw (
void)
58 if (this->vert_vbo ==
nullptr)
59 throw std::runtime_error(
"No vertex VBO set!");
61 if (this->shader ==
nullptr)
62 throw std::runtime_error(
"No shader program set!");
65 glBindVertexArray(this->vao_id);
75 for (std::size_t i = 0; i < this->vbo_list.size(); ++i)
76 this->assign_attrib(this->vbo_list[i]);
79 if (this->index_vbo !=
nullptr)
81 this->index_vbo->bind();
82 glDrawElements(this->primitive, this->index_vbo->get_element_amount(),
83 GL_UNSIGNED_INT,
nullptr);
88 glDrawArrays(this->primitive, 0, this->vert_vbo->get_element_amount());
92 this->shader->unbind();