WIP Hi-DPI support on HTMl5

grant

Member
CX Code Contributor
3rd Party Module Dev
3rd Party Tool Dev
Joined
Nov 19, 2019
Messages
80
I attached a modified version of html5game.js that has some modifications that enable hi-DPI support on HTML5. The modifications are marked with "grant Hi-DPI edit". It checks if the browser scaling (window.devicePixelRatio) has changed on each frame, so it will detect if the DPI changes mid game.

Also I added this line to the head tag of CerberusGame.html
Code:
<meta name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
 

Attachments

  • html5game.js
    13.9 KB · Views: 42
Last edited:

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
Does this effect performance and devices with no high-dpi support?

Edit: I guess not.
 
Last edited:

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
I wish you would have added your changes to the latest version of the html5games.js file. :-/
 

grant

Member
CX Code Contributor
3rd Party Module Dev
3rd Party Tool Dev
Joined
Nov 19, 2019
Messages
80
I see you got the latest version up for Mac yesterday. I'll grab it before my next changes.
 
Last edited:

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
Thanks, I have added it here:

 

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
As nobody mentioned any problems, I moved it to the develop branch.
 

MikeHart

Administrator
CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Joined
Jun 19, 2017
Messages
3,497
So, had time to test this more properly. Resizing a browser window or pulling the splitter in the window scaled up the canvas to an unusable size. :eek: Not good. Touch coordinates also report back wrong.
 
Last edited:
Top Bottom