transparent-cube

Minimal cross-platform native/wasm graphics example.
git clone git://git.amin.space/transparent-cube.git
Log | Files | Refs | README | LICENSE

commit 9f0b201485bef9194e718b13c524f6e99e14f45d
parent 1066509cd372b54bc3323abc416eec22420b8e0a
Author: amin <dev@aminmesbah.com>
Date:   Sun, 23 Jun 2019 19:17:28 +0000

Clean up resize code

FossilOrigin-Name: 418491b3a44eb64f8b3ce32c0d23b3740c755e38f860ba678baea59c9cf3a2de
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() {