Page 1 of 1

[Solved] love.resize OS difference?

Posted: Thu Oct 08, 2020 2:59 pm
by mhazaza
Does love.resize work different on Windows compared to Linux?
Resizing on Windows just freezes my app...I even tried to catch the change in window size manually in love.update() with no explicit resize callback involved but as long as the window the mouse button is held, all draw+game functions freeze on Windows 10. On Arch Linux it works just fine.
I looked it up in the wiki but the only thing tricky that's mentioned there was about fullscreen mode. I feel like i'm missing something, and appreciate every opinion you have on this. Thanks!
I have no os specific code i guess, so i feel like it's not about the code since it works fine with linux. I'll post my main.lua anyway...

Code: Select all

local display = Display:new()
local game = Game:new()
local resize
local scrolling
local scroll
function love.draw()
	if resize then
		love.graphics.setColor(0,0,0)
		love.graphics.rectangle("fill",0,0,love.graphics.getWidth(),love.graphics.getHeight())
	else
		display()
	end
end
function love.load()
	local pos = game:start()
	display:start(pos)
	buffer = display.pMap()
	display.pieces = new8x8(0)
	scroll = scrollFunction(display.pieces,buffer,function(m,m2,s)
		m[s.x][s.y] = m2[s.x][s.y]
		return s
	end)
	scrolling = 0
end
function love.update(dt)
	if resize then
		resize = resize + dt
		if resize > 0.5 then
			resize = false
			display:init()
		end
	end
	if scrolling then
		scrolling = scrolling + dt
		if scrolling > 1/60 then
			local s = scroll()
			if s then
				if display.float and s==display.float then
					display.pieces[s.x][s.y]=0
				end
				scrolling = scrolling -1/60
			else
				scrolling = false
			end
		end
	end
end
function love.resize()
	resize=0
end

Re: love.resize OS difference?

Posted: Thu Oct 08, 2020 6:14 pm
by zorg
Hi and welcome to the forums.

Windows itself pauses the main thread of processes when you drag or resize the window. Löve runs graphics (and everything else by default, as well) on the main thread.

Hence, yes, you will neither see anything drawn nor update during you doing those things in windows.

Re: love.resize OS difference?

Posted: Fri Oct 09, 2020 9:30 am
by mhazaza
Zorg, thank you so much!
I guess there is no way to catch this event before the main thread stops, right?