Thanks for all the input. I am actually looking for an easy and efficient way to update mesh data, because I like to experiment applying shaders, changing geometries, instancing and such all on the fly without having to worry too much about calling the render system to update the representation.
I was thinking about representing a mesh as a pure data structure, only containing triangles, vertices, etc and some useful methods to manipulate the mesh data. This mesh must be transformed to 'my-engine specific' vertex buffer description that the render system consumes (and stores into an openGL-vertex buffer object).
The digestion of the vertex buffer object leads to a collection of render calls in the render system. These calls are executed every frame and can be sorted for the least-amount of state changes. I was considering the following use case:
-
As a user of my engine, I like to easily change the appearance of a mesh, by assigning new materials to any (random) combination of triangles after the mesh has already been created.
For this to work the amount of render calls in the render system must be updated: I must find all render calls that belong to this geometry (leading to coupling between mesh and render system) and then possibly adding more render calls (because a single render call for 500 triangles with material A, can now be split into 200 triangles material A and 300 material B.
Q: But maybe I must just limit the interface to more common easy ways to change the appearance of the mesh, and if the user wants to change more specific things, it is responsible to call the render system to update the GPU representations.?