love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
5.09k stars 401 forks source link

w, h got old width and height in function love.resize(w, h) #2100

Closed zhengying closed 1 month ago

zhengying commented 2 months ago

macOS 13.4 intel x86, love2d 11.5

The w and h parameters should have a new width and height, but I got the old size. Is this a bug?

slime73 commented 2 months ago

Can you provide some code and steps to reproduce the issue for you?

zhengying commented 2 months ago

I noticed that it is actually called twice: the first time returns the old size, and the second time returns the new size. Is this by design?

reproduce step

1. new a simple main.lua :
function love.load()
    love.window.setMode(1024,768,{resizable=true})
end

function love.resize(w, h)
    print(tostring(w), tostring(h))
end

2. run it with love2d 11.5

3. resize window

5. see console log:
the result is :
1024    768
934     705   
slime73 commented 2 months ago

Thanks! I'm able to reproduce the issue. I'm not sure yet whether love's own event handling code has some bad assumptions around the order of SDL resize events, or if SDL is doing something weird with them. I'll need to investigate more.