Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buffer_data_with_u16_array to WebGlRenderingContext #1089

Closed
chinedufn opened this issue Dec 7, 2018 · 3 comments
Closed

Add buffer_data_with_u16_array to WebGlRenderingContext #1089

chinedufn opened this issue Dec 7, 2018 · 3 comments

Comments

@chinedufn
Copy link
Contributor

Right now there's a buffer_data_with_u8_array which is super convenient if you want o use WebGLRenderingContext::UNSIGNED_BYTE.

However, UNSIGNED_SHORT is probably more common, so buffer_data_with_u16_array would be super useful IMO.

Any reason that this shouldn't exist?

If not - I'd be happy to add it if you can point me in the right direction!

@chinedufn chinedufn changed the title Add buffer_data_with_u16_array Add buffer_data_with_u16_array to WebGlRenderingContext Dec 7, 2018
@alexcrichton
Copy link
Contributor

I believe that method is defined here which we expand here to an ArrayBuffer and a &mut [u8]. In theory any typed array can be accepted here but we just don't expand to all typed arrays, just a few. We could perhaps though add an &[u16] though!

Another option is #811 to create a Uint16Array from a &[u16] instance and then hand off the ArrayBuffer

@chinedufn
Copy link
Contributor Author

Thanks for the help - I'll send a PR for option 1. I'm assuming that nothing needs to be tested here but let me know if that isn't the case!

Thanks!!

chinedufn added a commit to chinedufn/wasm-bindgen that referenced this issue Dec 8, 2018
@chinedufn
Copy link
Contributor Author

I ended up going with this approach -> #918 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants