0
\$\begingroup\$

So - how do these work exactly?

Right now I am making a buffer and setting the data every frame for my object, but I heard you can reuse the buffer, too. If the object is not changing in any way besides it's position, can you reuse the same buffer every frame, or do you have to remake it?

I've also heard you can simply change the position in a shader - is this the way to go?

As far as I'm aware, if the object moves, you need to do this every draw call:

vertexbuff = new VertexBuffer(GraphicsDevice, VertexPositionColor.VertexDeclaration, _vertices.Length, BufferUsage.WriteOnly);
vertexbuff.SetData(_vertices, 0, _vertices.Length);
GraphicsDevice.SetVertexBuffer(vertexbuff);

At least, that's how it worked when I tried. Is there a way not to do this every frame or am I approaching this the only way possible?

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You can re-use the pointer to the buffer each step, but internally, the entire buffer is sent to the video card every step.

This restriction is a vestige of the original XNA behaviour.

Without some major wizardry, pointers across contexts are not possible at this time.

DX12 and Vulkan when implemented will solve this issue

A vertex shader parameter could handle the movement.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .