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 a Glow device abstraction #243

Conversation

@jnetterf
Copy link

jnetterf commented Nov 30, 2019

This implements GLOW (GL on Whatever) implementation of the device
abstraction. It is a very close copy of the GL implementation.

This abstraction can be used in multiple environments (Open GL, OpenGL
ES, and WebGL) and avoids target-specific code. The abstraction can be
used with wasm32-unknown-unknown + web-sys, stdweb, and natively.
I wrote this to enable limited WebGL 2 + wasm32-unknown-unknown support.

This also makes minor changes to shaders so that they work in WebGL 2
and implements an example that works both in web browsers and natively,
via SDL.

@jnetterf jnetterf mentioned this pull request Nov 30, 2019
This implements GLOW (GL on Whatever) implementation of the device
abstraction. It is a very close copy of the GL implementation.

This abstraction can be used in multiple environments (Open GL, OpenGL
ES, and WebGL) and avoid target-specific code. This can be used with
wasm32-unknown-unknown + web-sys, stdweb, and natively. I wrote this
to enable limited WebGL 2 + wasm32-unknown-unknown support.

This also makes minor changes to shaders so that they work in WebGL 2
and implements an example that works both in web browsers and natively,
via SDL.
@jnetterf jnetterf force-pushed the jnetterf:dev/jnetterf/glow-wasm32-unknown-unknown branch from f2f4ee2 to 7652461 Nov 30, 2019
Copy link
Collaborator

pcwalton left a comment

Is GLOW the emerging consensus for Rust OpenGL programs? I'd like to make sure that Pathfinder follows whatever the Rust ecosystem is doing and not splinter off into its own GL bindings. (WebRender unfortunately is tied to gleam, which little else in the Rust ecosystem uses, and I don't want to repeat that.)

name = "pathfinder_glow"
version = "0.1.0"
edition = "2018"
authors = ["Patrick Walton <pcwalton@mimiga.net>", "Joshua Netterfield <joshua@nettek.ca"]

This comment has been minimized.

@pcwalton

pcwalton Nov 30, 2019

Collaborator

nit: missing > at end of email

/// wasm32-unknown-unknown does not have a filesystem.
///
/// This does not have any platform dependencies, but will result in larger binaries, and slower
/// compile times, so you may wish to implement an approach with different trade-offs.

This comment has been minimized.

@pcwalton

pcwalton Nov 30, 2019

Collaborator

Hmm, have you considered using XHR or the Fetch API instead?

This comment has been minimized.

@jnetterf

jnetterf Dec 1, 2019

Author

Yes. This is likely something you would want to do outside of a minimal example. I'll explicitly mention this option in the comment. It may also be nice to provide such a loader in the future.

There are two reasons we may wish to avoid using a web API in this example. First, it's target-specific code that is not core to the example. Secondly, it requires a fair bit of setup, making the example harder to follow along with.

What do you think?

This comment has been minimized.

@pcwalton

pcwalton Dec 1, 2019

Collaborator

Well, my main concern is that it hardcodes all the pathnames of resources, which adds some maintenance burden.

@pcwalton
Copy link
Collaborator

pcwalton commented Nov 30, 2019

Also, we should just remove pathfinder_gl if we decide to go with GLOW. No sense having multiple versions of the GL backend.

Copy link
Author

jnetterf left a comment

Is GLOW the emerging consensus for Rust OpenGL programs? I'd like to make sure that Pathfinder follows whatever the Rust ecosystem is doing and not splinter off into its own GL bindings. (WebRender unfortunately is tied to gleam, which little else in the Rust ecosystem uses, and I don't want to repeat that.)

I don't have any special information, but I think it may be too early to describe GLOW as the "emerging consensus". While new, it is the most (only?) promising approach I've seen that supports both web-sys and native GL pointers. Note that for the native bindings, glow uses gl_generator, a part of the gl-rs crate pathfinder_gl uses. GLOW is a fairly light wrapper around those bindings, which made porting the gl device abstraction to glow straightforward. My understanding is that if another thin gl abstraction becomes a consensus, it would not be hard to again switch over to that.

Also, we should just remove pathfinder_gl if we decide to go with GLOW. No sense having multiple versions of the GL backend.

That makes sense, but I would suggest defering that so that you and others can raise issues that may arise with the glow device abstraction.

@jnetterf
Copy link
Author

jnetterf commented Jan 28, 2020

Closing in favour of https://github.com/s3bk/pathfinder

@jnetterf jnetterf closed this Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.