In OpenGL with shaders, I want to render two objects which I have loaded as two meshes. Each object is represented by a set of vertex positions, a set of vertex colours, and a set of vertex indices for the triangles.
There are three ways I can think of to draw the two objects. Which is the best practice?
1) I concatenate the vertex positions of the two objects into one long array of vertices, and similar for the vertex colours and the vertex indices. I then create one vertex position buffer, one vertex colour buffer, and one index buffer. When rendering, I then make one call to glBindBuffer(...)
and glDrawElements(...)
.
2) I concatenate the vertex positions of the two objects into one long array of vertices, and similar for the vertex colours. I then create one vertex position buffer, and one vertex colour buffer. When rendering, I then make two calls to glBindBuffer(...)
and glDrawElements(...)
, one for each object.
3) I create two vertex position buffers, two vertex colour buffers, and two index buffers. When rendering, I then make two calls to glBindBuffer(...)
and glDrawElements(...)
, one for each object.
Thanks!