You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Typo ad bug fixes to tut 1
* tutorial 2
Includes a bug fix for a bug I ran into. This is probably common on Macs with Retina displays, which have a default resolution of 3024 x 1964 for the 14"
* small typo
* Update README.md
Copy file name to clipboardExpand all lines: docs/beginner/tutorial1-window/README.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ impl State {
78
78
// ...
79
79
```
80
80
81
-
There's not much going on here, but once we start using WGPU will start filling this up pretty quick. Most of the methods on this struct are place holders, though in `render()` we ask the window to draw another frame as soon as possible as winit only draws one frame unless the window is resized or we request it to draw another one.
81
+
There's not much going on here, but once we start using, we WGPU will start filling this up pretty quick. Most of the methods on this struct are place holders, though in `render()` we ask the window to draw another frame as soon as possible as winit only draws one frame unless the window is resized or we request it to draw another one.
82
82
83
83
Now that we have our `State` struct, we need to tell winit how to use it. We'll create an `App` struct for this.
84
84
@@ -135,7 +135,7 @@ impl ApplicationHandler<State> for App {
@@ -180,7 +180,7 @@ The `resumed` method seems like it does a lot, but it only does a few things:
180
180
- It defines attributes about the window including some web specific stuff.
181
181
- We use those attributes to create the window.
182
182
- We create a future that creates our `State` struct
183
-
- On native we use pollster to get await the future
183
+
- On native we use `pollster` to await the future
184
184
- On web we run the future asynchronously which sends the results to the `user_event` function
185
185
186
186
The `user_event` function just serves as a landing point for our `State` future. `resumed` isn't async so we need to offload the future and send the results somewhere.
@@ -284,7 +284,7 @@ Now, all we need are some more dependencies that are specific to running in WASM
284
284
```toml
285
285
# This should go in the Cargo.toml in the root directory
286
286
287
-
#tThis is not required for WASM as wasm-opt should take care of this.
287
+
#This is not required for WASM as wasm-opt should take care of this.
288
288
# It can also interfere with WASM builds so feel free to leave it out.
289
289
# It helps if you are wanting to build native binaries, as it helps reduce
290
290
# the size of the executable, and make it harder to reverse engineer.
@@ -341,7 +341,7 @@ Now you can build a wgpu application with just wasm-bindgen, but I ran into some
341
341
342
342
To get around this shortcoming and to make the lives of everyone reading this easier, I opted to add [wasm-pack](https://drager.github.io/wasm-pack/) to the mix. Wasm-pack handles installing the correct version of wasm-bindgen for you, and it supports building for different types of web targets as well: browser, NodeJS, and bundlers such as webpack.
343
343
344
-
To use wasm-pack, first, you need to [install it](https://drager.github.io/wasm-pack/).
344
+
To use wasm-pack, first, you need to [install it](https://wasm-bindgen.github.io/wasm-pack/installer/).
345
345
346
346
Once you've done that, we can use it to build our crate. If you only have one crate in your project, you can just use `wasm-pack build`. If you're using a workspace, you'll have to specify what crate you want to build. Imagine your crate is a directory called `game`. You would then use:
This is where we configure the `surface`. We need the surface to be configured before we can do anything with it. We set the `is_surface_configured` flag to true here and we'll check it in the `render()` function.
241
241
242
+
Note that the max supported dimension in WebGL is 2048 px. If you have a larger display, you must cap the height and width, e.g.:
243
+
244
+
```rust
245
+
ifwidth>0&&height>0 {
246
+
letmax=2048;
247
+
self.config.width =width.min(max);
248
+
self.config.height =height.min(max);
249
+
```
250
+
242
251
## handle_key()
243
252
244
253
This is where we'll handle keyboard events. Currently just want to exit the app when the escape key is pressed. We'll do some other stuff later.
0 commit comments