MikePopoloski / SharpBgfx

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

Memory allocation from byte[] fails #16

Closed bostich83 closed 7 years ago

bostich83 commented 7 years ago

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

MikePopoloski commented 7 years ago

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.

bostich83 commented 7 years ago

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

Thanks anyway!