Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.49k stars 173 forks source link

[HTML5] Canvas has fixed size in the browser and its scale is proportional to the windows initial size #1492

Closed moisesjpelaez closed 6 months ago

moisesjpelaez commented 6 months ago

Describe the bug I have been using Armory3D to create a test demo, when I build the project in my main monitor it looks proportionally smaller in a web browser, since it's pixel ratio is 1.25. Another thing is that the canvas doesn't adjust according to the browser's window size, the canvas keeps a fixed size when I go full-screen or resize the browser's view.

Expected behavior The canvas should have the browser's window size and resize accordingly.

Screenshots Current normal size: image

Current full-screen size: image

Expected normal size: image

Expected full-screen size: image

Execution Environment: Using Armory3D 2024.02

Additional context This an issue related to what I'm saying, I believe this is the commit causing it since I already fixed it manually by modifying SystemImpl.hx.

RblSb commented 6 months ago

There is example in wiki how to override html5 resizing behavior: https://github.com/Kode/Kha/wiki/HTML5#full-page-canvas

moisesjpelaez commented 6 months ago

Yeah, I have seen it but doesn't project.addDefine('kha_html5_disable_automatic_size_adjust'); mean that it should disable the default html5 automatic size adjust? (which is the one I'm reporting)

Or a better question would be, why make the current automatic size adjust the default behavior?

RobDangerous commented 6 months ago

Kha doesn't handle canvas-resizing because a canvas element is usually embedded into a website that also does other things so Kha can't possibly know what to do.

moisesjpelaez commented 6 months ago

Kha doesn't handle canvas-resizing because a canvas element is usually embedded into a website that also does other things so Kha can't possibly know what to do.

I'm not sure I'm understand this answer and I'm wondering why the issue has been closed. The intended behavior shouldn't be to set the canvas size automatically in SystemImpl.hx? (which isn't doing it as expected)

I see that by modifying it as I mention here really solves the current issue without needing to override the canvas resizing behavior manually.

I also have to mention that I tested both the current version and the solution in 2 monitors, my phone and 2 different tablets with same results (same visual error and same expected result with the change I made to SystemImpl.hx). I also don't have much experience contributing to open source projects, so apologies in advance if I'm missing something.