What do you mean by static meshes?
Also if you wanna explain more about SubData feel free.
Well, I admit it can be a little hard to explain, but I'll try to answer both the above questions in one go.
First, by 'static' I just mean that the mesh data never changes after you initially create it.
When you allocate a buffer in OpenGL (using glBufferData), you get to supply a hint for how you expect the buffer to be used. For example, you'd specify 'static' if you never expect to change the buffer data after the initial upload, or 'stream' if you expect to change the data frequently. To the best of my knowledge these are just hints and don't actually have any effect on what you can or can't do with the buffer later, but for performance reasons you should try to choose a hint that matches how you intend to use the buffer.
In simple terms, glBufferData and glBufferSubData do the following:
- glBufferData allocates memory for a buffer, and optionally allows you to upload data to the buffer as well.
- glBufferSubData allows you to upload data to a buffer that's already been allocated via glBufferData.
So, glBufferData is more or less required (that is, you have to call it at some point if you want to use the buffer at all), but glBufferSubData is entirely optional and only need be used if you want to update the data in an existing buffer for some reason.
A lot of times in OpenGL you just want to create a mesh and never change it. This is often referred to as a 'static' mesh both because 'static' means unchanging, and also because the corresponding OpenGL usage hint is called 'static'. So whenever I say 'use a static mesh' I just mean to create a mesh once using glBufferData (with the 'static' usage hint), and then never change it.
Sometimes however you want to modify the data in an existing buffer. There are a lot of use cases for this: batching (like I was describing earlier), animation, deformation, and so on. The use case that could be of immediate interest to you, I think, is batching. But, to repeat myself, I don't think you necessarily need to start with that, as it can be a little complicated.
That's pretty long already, so I'll stop there, but feel free to ask for clarification if you need it.