-
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ffa86c
commit a0db16d
Showing
1 changed file
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, seems there is an error here :
if you want to apply the scale you should multiply it not divide, corrected it should be :
canvas.style.width = Std.int(clientWidth * scale) + "px";
canvas.style.height = Std.int(clientHeight * scale) + "px";
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, you need to set big canvas size and N times smaller canvas.style size, or canvas will have blur.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, we explicitly don't want to apply a scale. In Kha the user is responsible for handling dpi-scaling, therefore the backend should get to the raw pixels aka undo any scaling. See also the comment right above the code.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure blur is not good.
For web apps the scale is specify at the top in the meta header :
using : minimum-scale=1.0, initial-scale=1.0, maximum-scale=1.0
the scale will be 1.0 for all canvas.
then you can call the canvas with some specified pixels size: width='800' height='600'
and the canvas will resize to the wanted 800x600 size, that was done so it behave the same across browser and device with different DPI.
1/ If you divide the scale as above, the canvas won't fit the pixels size specified. (or else you have a way to resize the canvas?)
2/ If you divide the scale as above, if we want to render the canvas to a lower resolution and do some up-scaling (the canvas will not resize)
It just does not seems to be the way the Webgl canvas was intended to be used with DPI.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want to prevent blur, you should use this style for your content :
image-rendering: pixelated;
see more details here : https://developer.mozilla.org/en-US/docs/Web/CSS/Image-rendering
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly not what we want. Let's stop this here. As I said, if something doesn't work as intended, create a small sample-app showing it and open an issue.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious on which did you noticed the blurry effect ? on Safari iOS and Mac apple devices or was it on Chrome, or Firefox?
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On all of them. And with "pixelated" things are even worse.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well I can see your blurring issue when up-scaling the scale of the physical display and yes it's bad...
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just so you know,
I found that Blur is only showing when the scale is set above 100% on the physical device and in this case adjusting the scale in the meta header fixes the blur.
and if the scale become too big (like on an iPad), I change the canvas.width and width.height to an bigger value.
This way I have not detected any blur if the scale is correctly specified in the meta headers to 1.0 scale. :
<meta name="viewport" content="width=device-width, height=device-height, minimum-scale=1.0, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
I've run a few tests and with the last changes, Canvas sizes are now inconsistent across browsers as canvas.style sizes are forcibly specified.
I ran some tests on PC (Firefox/Chrome), MAC (Firefox/Chrome/Safari), iOS iPhone/iPad (Safari)
You can correct me if I am wrong here but now we cannot use 100vw or 100vh values for the canvas and the canvas.style
and so correctly center the canvas on all platforms without dedicated code for each platform.
Also the Webgl canvas does not resize according to the scale in the meta headers anymore.
Which from a webdesign standpoint looks like a step backward, removing the flexibility to use the scale.
This point is valid except if you are targeting one platform in particular and don't bother the other platforms.
a0db16d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said before, create a minimal sample, open an issue, tell us what happens and what you expect to happen instead. And use the generated html for that.