I am trying out OpenGL again and I'm wondering how to design the classes that are rendered later on. Right now, there's is only one type of shapes, and so I created a class Shape
with a static VAO member that glGenVertexArrays(1, &vao)
is called on when the first instance of Shape
is created. Now there's a method void Shape::render()
:
void Shape::render()
{
glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, foo, bar);
}
Is this a good way to go? I mean, when all the instances of Shape
are drawn in the actual program, there is the recurring call to bind Shape::vao
, but my guess would be that it doesn't actually do anything if vao
is already bound currently. Is that guess correct?
Also, I saw a tutorial some time ago that used to call glBindVertexArray(0)
at the end of render()
. Wouldn't that be a potential performance loss when there are many shapes?