diff --git a/src/content/docs/cheerp/01-tutorials/03-pong.md b/src/content/docs/cheerp/01-tutorials/03-pong.md index 85362f31..ad9d5b85 100644 --- a/src/content/docs/cheerp/01-tutorials/03-pong.md +++ b/src/content/docs/cheerp/01-tutorials/03-pong.md @@ -238,6 +238,7 @@ void Graphics::keyDownHandler(client::KeyboardEvent* e) platform.moveRight(400); } ``` + Notice that we are using `fmin` and `fmax` instead of the usual `std::min`/`std::max`. In general, standard library (STL) functions are compiled to Wasm. We can use STL functions from the JS code but there are restrictions. One of these dictates that Wasm functions that have pointers or references to basic types are not available in the JS-annotated part of the code. Indeed, `std::min`/`std::max` get references to basic types while `std::fmin`/`std::fmax` get their inputs by copy. Another solution would have been to wrap `std::min`/`std::max` in non-JS-annotated functions that take `int`s by copy. This limitation will hopefully disappear at some point in the future. Let's also register an `EventListener` in `Graphics::initializeCanvas`.