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 WebGL Extensions #51

Merged
merged 3 commits into from
Oct 15, 2019
Merged

Add WebGL Extensions #51

merged 3 commits into from
Oct 15, 2019

Conversation

TannerRogalsky
Copy link
Contributor

This enables and tracks all supported WebGL extensions. It also uses those extensions to add vertex array objects and instanced drawing to WebGL1 when supported.

Some areas of potential interest:

  • stdweb's VAO extension implementation returns a different type than the non-extension implementation. I've resolved this by tracking the extension resource separately but with the same key type.
  • WebGL extensions are all [NoInterfaceObject]s and aren't represented as JS classes and therefore can't be cast into Rust classes in the normal way (using JsCast::dyn_into). Instead unchecked_into is used along with the web_sys-provided Rust classes to duck-type these extensions. As I understand it, this is the expected way.
  • I've employed a macro to cut down on code duplication around the web_sys extension creation because their WebGL1 and WebGL2 context share an API but not a useful trait.

I'm of course open to any suggestions on how to improve this.

Copy link
Owner

@grovesNL grovesNL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great, thank you! 👍

I guess the next step for optional features/extensions is to expose queries to check at run-time whether they're supported. Similar to the existing supports_debug, we could have supports_instancing, etc.

bors r+

bors bot added a commit that referenced this pull request Oct 15, 2019
51: Add WebGL Extensions r=grovesNL a=TannerRogalsky

This enables and tracks all supported WebGL extensions. It also uses those extensions to add vertex array objects and instanced drawing to WebGL1 when supported.

Some areas of potential interest:
- stdweb's VAO extension implementation returns a different type than the non-extension implementation. I've resolved this by tracking the extension resource separately but with the same key type.
- WebGL extensions are all `[NoInterfaceObject]`s and aren't represented as JS classes and therefore can't be cast into Rust classes in the normal way (using `JsCast::dyn_into`). Instead `unchecked_into` is used along with the web_sys-provided Rust classes to duck-type these extensions. As I understand it, [this is the expected way](rustwasm/wasm-bindgen#1449).
- I've employed a macro to cut down on code duplication around the web_sys extension creation because their WebGL1 and WebGL2 context share an API but not a useful trait.

I'm of course open to any suggestions on how to improve this.

Co-authored-by: Tanner Rogalsky <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 15, 2019

Build succeeded

@bors bors bot merged commit 3fc9ee3 into grovesNL:master Oct 15, 2019
@TannerRogalsky TannerRogalsky deleted the extensions branch October 15, 2019 10:34
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

Successfully merging this pull request may close these issues.

2 participants