MikePopoloski / SharpBgfx

C# bindings for the bgfx graphics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory allocation from byte[] fails

bostich83 opened this issue · comments

Hi Mike,
while using your library, i came up with the following "bug" (not sure if its just me)

Please consider the following snippit:

byte[] data = new byte[1];
var block = MemoryBlock.FromArray(data);

It crashes with a System.AccessViolationExcetion, on NativeMethods.bgfx_copy, unless bgfx.Init was called

Since there is no source code for the C-Interface (unless iam missing something :) ), i can't figure what's wrong.

Best regards,
//Christian

The source code for the C interface is in the bgfx library: https://github.com/bkaradzic/bgfx

SharpBgfx is just a wrapper around that. The bgfx allocator isn't initialized until you call Init(), so there's no way around that.

I see!
Sorry,i didn't have a closer look @ the native source and wasn't aware of the c exports...

Thanks anyway!