sharpgl icon indicating copy to clipboard operation
sharpgl copied to clipboard

Add uint overload for BufferData to OpenGLExtensions

Open jochemgeussens opened this issue 11 years ago • 2 comments

Dear Sir

I'm really grateful for the ushort[] and float[] overload to BufferData, as I previously had no experience with IntPtr's. So this was a good example to get started with it. But for larger data (>65k) ushort is not an option as index buffer. So could you consider adding a uint overload as well. I created an extension method for it at the moment.

I think you can just copy paste this into OpenGLExtensions:

    public void BufferData(uint target, uint[] data, uint usage)
    {
        var dataSize = data.Length * sizeof(uint);
        IntPtr p = Marshal.AllocHGlobal(dataSize);
        var intData = new int[data.Length];
        Buffer.BlockCopy(data, 0, intData, 0, dataSize);
        Marshal.Copy(intData, 0, p, data.Length);
        InvokeExtensionFunction<glBufferData>(target, dataSize, p, usage);
        Marshal.FreeHGlobal(p);
    }

Kind regards, Jochem.

jochemgeussens avatar May 01 '14 14:05 jochemgeussens

Hi Jochem,

Thanks for getting in touch and the code sample - I will include it in the next release :)

dwmkerr avatar May 04 '14 08:05 dwmkerr

I have implemented it on my version, pretty quick. There is a little drop of FPS du to the 32 bits dataset but it works fine with around 50FPS for large meshes. (I couldn't find any Dll with that option for SharpGL)

laurentchougrani avatar Sep 01 '17 13:09 laurentchougrani