Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default HTML-5 export option forces scaling to fit viewport, even for non-resizable games #37205

Closed
madprogramer opened this issue Mar 21, 2020 · 1 comment · Fixed by #42178

Comments

@madprogramer
Copy link

Godot version:
3.2
OS/device including version:
MacOS
Issue description:
Default HTML-5 export option forces scaling to fit viewport, even for non-resizable games
Steps to reproduce:
Use HTML-5 export for any project, compare the visible screen in Godot with the HTML-5 version when running.
Minimal reproduction project:
Any project with a pre-specified window width/height, smaller than the viewport it'll be run in.

Quick-Fix:

Open up the Project.html of your export in a text-editor.
Scroll down to the line

function adjustCanvasDimensions() {

change the function from

function adjustCanvasDimensions() {
	var scale = window.devicePixelRatio || 1;
	var width = window.innerWidth;
	var height = window.innerHeight;
	canvas.width = width * scale;
	canvas.height = height * scale;
	canvas.style.width = width + "px";
	canvas.style.height = height + "px";
	}

to

function adjustCanvasDimensions() {
	canvas.width = innerWidth;
	canvas.height = innerHeight;
        }
@Calinou
Copy link
Member

Calinou commented Mar 21, 2020

If you want the project to display at a fixed size, you can use the fixed size HTML template.

  1. Save this HTML template as a file.
  2. In the editor, open the Export dialog, select your HTML5 export preset, specify a custom HTML template and point to the file you saved.
  3. Export your project.

That said, I would advise making your game window resizable so it handles multiple aspect ratios and hiDPI 🙂

@Calinou Calinou changed the title Issue? Default HTML-5 export option forces scaling to fit viewport, even for non-resizable games Default HTML-5 export option forces scaling to fit viewport, even for non-resizable games Mar 21, 2020
@akien-mga akien-mga added this to the 4.0 milestone Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants