transparent-cube

Minimal cross-platform native/wasm graphics example.
Log | Files | Refs | README | LICENSE

commit 7f9aead11126e2b3d7badbaa3eb3f702acb0aa84
parent 1539bdcf09db13476f3a29ae9553590a7fa4ab99
Author: Amin Mesbah <dev@aminmesbah.com>
Date:   Sun, 23 Jun 2019 12:17:28 -0700

Clean up resize code

Diffstat:
Mjs/loader.js | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/js/loader.js b/js/loader.js @@ -2,10 +2,13 @@ function canvas_resize() { let pr = window.devicePixelRatio; let w = window.innerWidth; let h = window.innerHeight; - gl.canvas.width = (w * pr) | 0; - gl.canvas.height = (h * pr) | 0; - exports['window_resize']((w * pr) | 0, (h * pr) | 0); - console.log("resize: [" + (w * pr | 0) + ", " + (h * pr | 0) + "] > [" + (w | 0) + ", " + (h | 0) + "]"); + // Bitwise OR does float truncation + let w_pixels = (w * pr) | 0; + let h_pixels = (h * pr) | 0; + gl.canvas.width = w_pixels; + gl.canvas.height = h_pixels + exports['window_resize'](w_pixels, h_pixels); + console.log("resize: (" + w_pixels + ", " + h_pixels + ")"); } function canvas_render() {