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
API to get device scale for handling high-DPI mode manually #395
Comments
Detecting DPi is something i need, so that i can then scale everything properly and do constraint based layout. Is there anything in Ebiten yet for detection of DPI ? |
Not so far, and let me think if I should make the API. This is risky because this might break assumptions of Ebiten's graphics system. |
I can see what you mean about risky as you presume a fixed X and Y screen space. |
In #469 @hajimehoshi said
Another API I can think if is |
My concern is not only making My current idea is to add |
Now I have implemented on desktops and not on browsers and mobiles. (not pushed yet) I found another concern: if auto-scaling is disabled, what if fullscreen scaling? Probably making the game fullscreen without scaling would be the answer, but this would be the first case that |
Yet another concern: As MacBook (Pro) or iPhone can't render pixel-perfect way, this option might not be useful for 'perfectly-crisp' rendering. |
Oh, I came up with much more elegant solution! Assuming we have
As a result, auto scaling by device scale would be invalidated without introducing a new state to Ebiten. What I have to do is add @megapctr, do you think this would work in your case? |
Wouldn't that stretch the image back and forth? If not then it's great :) I'll try this in a moment |
It's not. Actually the number of scaling is not changed and the final scale (1/devicescale * devicescale = 1 in this case) is just adopted. |
I just tried this, works perfectly 👏 Thank you very much! |
d18fc36 Added
Oh, I'm glad to hear that! |
As for the fullscreen issue, I think we'd need to know the screen resolution. Knowing this, if user wants to toggle fullscreen, the Perhaps this code will better explain the idea: var enableFullscreen = errors.New('enableFullscreen')
var width, height = 800, 600
func main() {
while true {
err := ebiten.Run(update, width, height, 1 / ebiten.GetDeviceScale(), "My app")
if err == enableFullscreen {
width, height = ebiten.GetScreenResolution() /* new api? */
ebiten.SetFullscreen(true)
} else if err != nil {
panic(err)
}
}
}
func update(screen *ebiten.Image) error {
return enableFullscreen
} By the way, is it even possible for |
Yeah I agree we need to have a new API for screen resolution. I think we should have another ticket.
This returns nil when the window is closed. IIUC there are not other cases. If you want to terminate the game without errors, you can define an error value, return this in update func, and detect this at |
No description provided.
The text was updated successfully, but these errors were encountered: