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 typesafe version of get_parameter #315

Open
sagudev opened this issue Oct 20, 2024 · 0 comments
Open

Add typesafe version of get_parameter #315

sagudev opened this issue Oct 20, 2024 · 0 comments

Comments

@sagudev
Copy link
Contributor

sagudev commented Oct 20, 2024

Currently user needs to know what kind of data will query to get parameter return, this is error prone. Instead I propose get_parameter that gets it's target argument via generic (ex: gl.get_parameter::<ALPHA_BITS>()), so we can dispatch to proper type at compile time without worrying user what kind of function call should be used (this would also make porting WebGL code to rust easier).

I have a rough prototype of how this implementation would look like in this playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c6922a88ef3d74c8890f70ee79d21f1c

This would be backwards compatible, but get_parameter must not be added to HasContext as it would make it not object safe due to generic arguments.

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

1 participant