When I don't pass the datas to a generic class, it works :
if (vboVertexBuffer == 0) {
GLuint vbo;
glCheck(glGenBuffers(1, &vbo));
const_cast<VertexArray*>(this)->vboVertexBuffer = static_cast<unsigned int>(vbo);
glCheck(glBindBuffer(GL_ARRAY_BUFFER, vboVertexBuffer));
glCheck(glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertices.size() * sizeof(Vertex), &(m_vertices[0]), GL_DYNAMIC_DRAW));
} else {
GLvoid *pos_vbo = nullptr;
glCheck(glBindBuffer(GL_ARRAY_BUFFER, vboVertexBuffer));
pos_vbo = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
if (pos_vbo != nullptr) {
memcpy(pos_vbo,&m_vertices[0], m_vertices.size() * sizeof(Vertex));
glCheck(glUnmapBuffer(GL_VERTEX_ARRAY));
pos_vbo = nullptr;
}
glCheck(glBindBuffer(GL_ARRAY_BUFFER, 0));
}
if (vboVertexBuffer == 0) {
GLuint vbo;
glCheck(glGenBuffers(1, &vbo));
const_cast<VertexArray*>(this)->vboNormalBuffer = static_cast<unsigned int>(vbo);
glCheck(glBindBuffer(GL_ARRAY_BUFFER, vboVertexBuffer));
glCheck(glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_normals.size() * sizeof(Vector3f), &(m_normals[0]), GL_DYNAMIC_DRAW));
} else {
GLvoid *pos_vbo = nullptr;
glCheck(glBindBuffer(GL_ARRAY_BUFFER, vboVertexBuffer));
pos_vbo = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
if (pos_vbo != nullptr) {
memcpy(pos_vbo,&m_normals[0], m_normals.size() * sizeof(Vector3f));
glCheck(glUnmapBuffer(GL_VERTEX_ARRAY));
pos_vbo = nullptr;
}
glCheck(glBindBuffer(GL_ARRAY_BUFFER, 0));
}
But it's quite anoying to don't have the possibility to encapsulate them in a class.