-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
Initial WebGL2 support. #218
Conversation
parasyte
commented
Oct 28, 2021
- Closes WASM support #115
- This prevents some hard-to-debug footguns - Also fixes some minor things in the WebGL2 example
There are some things I don't really like about this example. Most annoying is that |
The WASM CI task does take a few more minutes because it needs to install |
I had a similar experience when porting Sandbox to wasm. I'm starting to think it might be a good idea to offer a winit feature for pixels that would integrate things more - wasm setup, simplified input handling, etc. What are your thoughts? |
Yep, thought about that very briefly. I don't want winit as a direct dependency, but we can absolutely wrap up the boilerplate into its own crate. As long as it can take care of things like resize, I believe that would be a huge improvement over rolling your own WASM container. |
I think I got a version of this example going that has some resize capability, but it's kinda janky. It doesn't smoothly resize, but jumps to bigger and bigger sizes based on the current browser window size. I honestly wasn't too sure what I was doing, just used other code I found as a template and sort of fiddled with it to get it going. So I'm not sure if I can figure how to get it resizing smoothly, but I'll still give it a shot. If I get it working, is there a way to include the changes in this specific pull request? |
@MarkAnthonyM You can create a PR against the FWIW, I looked briefly at how the It may or may not be useful, but it's an extra datapoint and some prior art in the area. |
Resize support would be great! Is the non-smooth resizing not just pixels only snapping to integer multiples? I.e., pixels won't scale your game by 1.343 or anything, only 1x, 2x, 4x, etc... |
The linked gif looks correct, to me. 🤷 |
@JMS55 Oh ok, I didn't know about that I was under the impression that the height and width of pixel's rendering area was suppose to grow at the same height and width values that the browser client does. Like following closely to the edges of the browser window, leaving no black borders. Now that I think about it a little bit, I guess that wouldn't really make sense from pixel's perspective. In that case, if this is the expected behavior, I'll just clean up the code and send off a PR. |
The expected behavior can be accomplished on the caller-side. For instance, the pixels/examples/imgui-winit/src/main.rs Lines 102 to 113 in eb07e61
That sounds good to me! Thank you. |
I think your idea for abstracting away the fluff currently in main makes sense. I can't think of anything else other then decorating stuff with macros, but that seems a little overkill. I did a quick dry run, as I wasn't sure what the signature of
|
Me too. I came up with: pub fn app(future: impl Future<Output = ()> + 'static)
After I put my thoughts into usable code, I recognized that it doesn't have any relation to It doesn't seem to matter where it lives. Either here (a top-level crate as you've shown) or in another repo by another owner entirely... I am hesitant to reorganize this repo just for a new top-level crate that only indirectly has anything to do with the main library. You can create a new repo for it if you like! Or if you would rather have someone else maintain it, I can. |
- Set the background color to black (matches the border color used by `pixels`) - Remove the margin and scroll bars
- Copy index.html to the target directory - Do not produce typescript output - Add a recipe to clean the target directory
- The `PixelsBuilder::build_async` recommendation was accidentally added to the wrong constructor. - Examples should reference `wgpu` through the reexport. - Minor simplifications like `use` and removing unnecessary `let` bindings. - Normalize all hidden `SurfaceTexture`s in examples to use the same size as the pixel buffer. This is just my OCD showing. Nothing to see here.
Yea, I'll throw the crate together as a separate repo and maintain it. At least until winit figures out how exactly it wants to handle the situation related to the resizing boilerplate. That leaves me wondering about main again though... Anyway, I'll send another PR to update the example when I get everything going |
I read in one of the winit issues that it will also need a similar workaround to receive mouse and touch events. And I’m sure it could grow into something of a stop-gap for several web events that winit doesn’t support yet. |
- Enables all `wgpu` backends on WASM targets by default
I think this is pretty much done from the Any thoughts from collaborators? |
- This one looks quite a bit different with the CSS and resize working!
Since no one has responded over the weekend, I'll take that as good-to-go. 🙂 |