Calling Module.toggleFullscreen() in the HTML5 build correctly enters full screen on hidpi devices (Android Chrome), but doesn’t multiply canvas.width and canvas.height with window.devicePixelRatio || 1.
The change needs to be operated in _glfwSwapBuffers() and onFullScreenEventChange().
Not really. You can get good results in windowed mode if you do what that issue recommends (set the canvas size with css and the canvas’s backing size with Module.setCanvasSize), but specifically in full screen mode you don’t have good control and the engine needs to accomodate for that.
I’ve added your info to the same ticket as I believe they should be solved together. If @sven doesn’t agree with me we’ll split it into two issues and update this post.
Because on mobile devices browser logical width == 320…480px we need write some trick.
And this trick is set canvas.style.width to 100% but canvas.width to window.innerWidth*devicePixelRatio;
I set Canvas style.width in css (see header).
If you can’t set canvas style properly then mobile browser setup wrong size of page.
Also your defold render script should react to changing app resolution: render.get_window_width() and render.get_window_height()
Another good solution is using maximize-canvas script: https://github.com/sergebat/maximize-canvas (for properly working this script required to creating canvas in code, not preset in html)
I’m running Defold 1.2.188 and I’m still getting blurry HTML5 exports (fonts, images, etc) on hi-dpi displays.
In looking at /builtins/manifests/web/engine_template.html I noticed that there is no code dealing with window.devicePixelRatio (as @Dragosha) illustrates in his HTML5 template above.
I added the following at line 130:
var dpi=window.devicePixelRatio || 1
And added ‘* dpi’ to lines 197 and 198:
game_canvas.width = width * dpi;
game_canvas.height = height * dpi;
The default template now renders to hi-dpi displays.
I also didn’t see any {{#DEFOLD pragma}} statement for hi-dpi displays, just in-case that was not being picked up from the game.project file.