MikePopoloski / SharpBgfx

C# bindings for the bgfx graphics library
MIT License
169 stars 32 forks source link

How to use TransientVertexBuffer #5

Closed KrzysztofMajor closed 8 years ago

KrzysztofMajor commented 8 years ago

Could you please write an example how to fill TransientVertexBuffer. It's straight forward in C++ but not so obvious in C#

MikePopoloski commented 8 years ago

What exactly are you having trouble with?

The idea is that you allocate one on the stack each frame, copy data to its IntPtr Data member, and then call SetVertexBuffer on it to bind it and render from it.

If you're not sure how to copy to an IntPtr, there are many different ways in C#. See Marshal.Copy, Buffer.MemoryCopy, or just cast it to a pointer and then set vertex data directly.