Hello y'all! I'm working on a game and noticed a weird resizing issue. Would love some help!
When I run a resizable game, drag the game window to my HD monitor, and resize it there, the game fails to resize correctly and doesn't fill the window. I opened a bug ticket which includes more precise reproduction steps + tech specs: https://bitbucket.org/rude/love/issues/ ... resizes-on
If anyone's run into this before and knows of any stopgap solutions, I'd be super appreciative! I assume it's related to a mismatch in resolution/DPI between my monitor and my laptop. I searched the forums and tried t.window.highdpi = true but that didn't seem to help.
Thanks!
Correctly resizing window on HD monitor?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Correctly resizing window on HD monitor?
Hello & welcome!
The bug is not reproduced on my 4k config on Windows with different DPI settings.
Maybe it's only MacOS feature...
It will be interesting to look at the window resolution, obtained by love in this case. Can you add this code:
in the bottom of the love.draw() function and look at the printed dimensions after this bug occures? On the different monitors?
I've got something like this https://monosnap.com/direct/cjfbznW9IlX ... RtEyHDzpgN
The bug is not reproduced on my 4k config on Windows with different DPI settings.
Maybe it's only MacOS feature...
It will be interesting to look at the window resolution, obtained by love in this case. Can you add this code:
Code: Select all
local w, h = love.graphics.getDimensions()
love.graphics.print(("window %d x %d"):format(w, h), 4, 10)
local _, _, flags = love.window.getMode()
local width, height = love.window.getDesktopDimensions(flags.display)
love.graphics.print(("display %d: %d x %d"):format(flags.display, width, height), 4, 30)
I've got something like this https://monosnap.com/direct/cjfbznW9IlX ... RtEyHDzpgN
Re: Correctly resizing window on HD monitor?
Initially:
window 500 x 500
display 1 1680 x 1050
After resizing successfully on my laptop monitor:
window 726 x 500
display 1 1680 x 1050
After failing to render properly after resizing on my external monitor:
window 679 x 500
display 2 1920 x 1080
window 500 x 500
display 1 1680 x 1050
After resizing successfully on my laptop monitor:
window 726 x 500
display 1 1680 x 1050
After failing to render properly after resizing on my external monitor:
window 679 x 500
display 2 1920 x 1080
Re: Correctly resizing window on HD monitor?
Ah, and the monosnap you shared looks to be rendered correctly! Here's what it looks like when I resize the window on my external HD monitor: http://www.giphy.com/gifs/cmgGlbgcUR7zW2Di9x
Not only does it not properly render the game in the yellow area, but resizing vertically also inappropriately offsets the rendered area vertically.
Not only does it not properly render the game in the yellow area, but resizing vertically also inappropriately offsets the rendered area vertically.
Re: Correctly resizing window on HD monitor?
Hm.. this resolutions seems ok.
Another guess: what if you change window not by mouse, but from the code? For example with this code, added to the buttom of the main.lua file?
So, it must change the window when you press 5, 9 or 0 keyboard buttons. Will the bug reproduce?
Another guess: what if you change window not by mouse, but from the code? For example with this code, added to the buttom of the main.lua file?
Code: Select all
function love.keypressed(key)
if key == "5" then
love.window.setMode(500, 500)
elseif key == "9" then
love.window.setMode(900, 500)
elseif key == "0" then
love.window.setMode(1200, 500)
end
end
Re: Correctly resizing window on HD monitor?
Wow!! The gif you shared looks really weird
I recommend to add it in your bitbucket ticket, because it perfectly describes the behavior.
I recommend to add it in your bitbucket ticket, because it perfectly describes the behavior.
Re: Correctly resizing window on HD monitor?
Calls to setMode will transfer the LÖVE window back to my laptop screen, which is my primary monitor. And actually, if I swap it such that my HD monitor is my primary monitor, then LÖVE resizes just fine on my HD monitor but has the same resize failure when resizing it on my laptop. So I guess it's just that whichever screen is "secondary" will be the one where the resize fails.
Re: Correctly resizing window on HD monitor?
Ok, let's save and set window position and display index with that:
And I also replaced setMode with updateMode. This shouldn't make a difference here, but looks nicer.
Generally I am sure that this behaviour is a bug and must be fixed.
But at the moment maybe there is a workaround if:
Code: Select all
function love.keypressed(key)
local x, y, display = love.window.getPosition()
if key == "5" then
love.window.updateMode(500, 500, { x = x, y = y, display = display })
elseif key == "9" then
love.window.updateMode(900, 500, { x = x, y = y, display = display })
elseif key == "0" then
love.window.updateMode(1200, 500, { x = x, y = y, display = display })
end
end
Generally I am sure that this behaviour is a bug and must be fixed.
But at the moment maybe there is a workaround if:
- setMode / updateMode can resize window corectly on your secondary monitor
- and you can obtain correct window size with love.graphics.getDimensions()
Re: Correctly resizing window on HD monitor?
Well this is interesting! If I add this to my code:
Then what happens is I can drag the LÖVE window to any screen/monitor, and if I then press a key it'll become "attuned" to that screen (for lack of a better word). And from then on the window will resize correctly on that screen. If I then drag the window to any other screen/monitor, it'll fail to resize properly until it's "attuned" to that screen by pressing another key while it's on that screen.
So... weird! I might be able to leverage this to craft a workaround for my purposes. But if this an issue that's solved by calling updateMode with basically meaningless arguments, it seems it might be within LÖVE's reach to resolve the issue. Though reproducing the issue on anyone's computer other than mine seems to be the hardest part.
Code: Select all
function love.keypressed(key)
local width, height = love.window.getMode()
love.window.updateMode(width, height)
end
So... weird! I might be able to leverage this to craft a workaround for my purposes. But if this an issue that's solved by calling updateMode with basically meaningless arguments, it seems it might be within LÖVE's reach to resolve the issue. Though reproducing the issue on anyone's computer other than mine seems to be the hardest part.
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Correctly resizing window on HD monitor?
updateMode will destroy and recreate the entire window and OpenGL context, which (aside from being noticeable to the user) has the side effect of clearing all Canvases - so if love did that internally, it would break a lot of games. It's definitely a good starting point for further investigation though.
(The underlying problem is also almost guaranteed to either be an issue in SDL's own source code or a bug in macOS itself, rather than something love's source code is doing on its own, so any fix or workaround is likely to happen in SDL's code rather than love's.)
(The underlying problem is also almost guaranteed to either be an issue in SDL's own source code or a bug in macOS itself, rather than something love's source code is doing on its own, so any fix or workaround is likely to happen in SDL's code rather than love's.)
Who is online
Users browsing this forum: Ahrefs [Bot], monsieur_h and 5 guests