I'm learning DirectX right now, I read alot about VertexBuffer. Since you cant learn from programming by just reading, I'm making a small Engine with DX11 (Well my question isn't really version dependent)
As far as I understood in a VertexBuffer I store Vertices, and actually I store it on the Graphic card. Well I read about dynamic and static buffers. So If I understand correctly, a static buffer is initialized with vertices and the initialized vertices wont change. OKay but when do I really need it. I mean in a Game or whatever, when do I have constant vertices? Maybe for some UI objects..? - but even these aren't constant everytime.. you can move their 2D position... etc..
The next point is about dynamic vertex buffers, for example: I have a Buffer with some vertices in it, these vertices are drawn. Then I want to add or remove some vertices. What now.. So I would simply "update" the buffer. But is this really right and good for performance? Imagine a terrain editor. There you have to update tons of vertices.
I mean in a Game or whatever, when do I have constant vertices?
All the time actually. For example, static geometry, the UI objects you mentioned etc. There is a slight misunderstanding on your part about moving objects, hence the confusion - you don't move objects by changing their vertices. Instead, you will put your vertices through the shader pipeline. In the vertex shader, you can apply arbitrary transformations to your vertices. So, for example, if you have a tree that's moved around the world for some reason (maybe it's on a floating island or something), rather than changing the vertices that make up the tree, you change the transformation that is applied to the vertices.
Imagine a terrain editor
It depends on what your terrain editor is supposed to do, but generally you again aren't going to change vertices here. I.e. when editing the height, rather then moving vertices up and down, you write to a height map (most of the time a greyscale texture), and again compute the transformation on the GPU in the shader pipeline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With