Allow typed arrays as parameter for texImage2D
thomz12 opened this issue · comments
Thom Zeilstra commented
For some reason I can't use a typed array for the texImage2D
and texSubImage2D
functions.
Uint8Array platformData = new Uint8Array(data);
_gl.texImage2D(_gl.TEXTURE_2D, 0, _gl.RGBA, width, height, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, platformData);
Casting it to an ArrayBufferView works with H5:
Uint8Array platformData = new Uint8Array(data);
ArrayBufferView view = (object)platformData as ArrayBufferView;
_gl.texImage2D(_gl.TEXTURE_2D, 0, _gl.RGBA, width, height, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, view);
It used to work in Bridge.NET, is this a bug?
theolivenbaum commented
Strange, I didn't remove anything with the fork, but should be an easy fix. Meanwhile you can also use the .As<ArrayBufferView>()
method to cast it to the other type - this is a nop when converted to javascript and in C# it will not check if the type can be casted - it exists for these cases to make it more legible.