Page 1 of 2

Black area while resizing window

Posted: Thu Jan 30, 2025 11:26 pm
by dcuny
When resizing a Love window in Windows, the "new" area that is exposed is rendered black until the resize operation is complete.

Is there a flag that allows this to be updated during the resize, or is this a limitation of the underlying graphics library?

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 5:57 am
by dusoft
Check love.resize function. You will need to provide whatever calculations for making your draw/screen area larger here.

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 5:33 pm
by dcuny
Hi, dusoft.

Thanks for the response, but I think I didn't describe the issue well.

Once the resize operation is done and the mouse button is released, I have no problems dealing with it. As you mentioned, love.resize passes that information on the program, and I can perform any adjustments I need so love.paint works with the new window size.

The "problem" is that while the drag operation is going on during the window resizing, there's no love.resize messages being sent, and there's no love.draw operation happening. That only happens on the mouse release of the resize operation. So any areas that are exposed during the drag are painted black.

If I do something like:

Code: Select all

function love.resize()
  print("resizing")
  io.flush()
end
It won't print any events while it's resizing, so that verifies that it only triggers once the window is resized.

Similarly, if I try:

Code: Select all

local count = 1
function love.draw()
  -- set window background color
  love.graphics.clear(GREY)
  love.graphics.setColor(GREY)
  love.graphics.rectangle("fill", 1, 1, 1000, 1000)
  print("draw", count)
  count = count + 1
  io.flush()
end
The draw event stops triggering during the resize event.

It's as if the underlying toolkit stops processing messages during the Windows resize event.

Google claims that LOVE2D uses the ANGLE library to handle graphics. But other programs that use ANGLE (for example, Godot) don't see to have this limitation. So I assume that it's not a limitation of the graphics library.

I redefined love.run as:

Code: Select all

local c = 1
function love.run()
	if love.load then love.load(love.arg.parseGameArguments(arg), arg) end

	-- We don't want the first frame's dt to include time taken by love.load.
	if love.timer then love.timer.step() end

	local dt = 0

	-- Main loop time.
	return function()
    
      c = c + 1
      print("run", c)
      io.flush()
      
      ...
      
And it looks like run doesn't trigger during the window drag, either. So there doesn't seem to be any obvious way to force Love2D to trigger an event during a resize.

Is there some way to make Love2D repaint while a resize drag is happening?

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 6:26 pm
by dusoft
Ah, not sure about this, maybe somebody else can chip in... But just to run you through some ideas:

Does love.update run during resizing?

I see this:
If love.window.setMode has vsync equal to true, this function can't run more frequently than the refresh rate (e.g. 60 Hz), and will halt the program until ready if necessary.
mentioned here: https://love2d.org/wiki/love.graphics.present

You can try play with both present() and vsync value, if that changes anything.

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 7:17 pm
by dcuny
Thanks!

After the last post, I looked all the flag options.

Turning sync on or off makes no difference.

I suspect it was a design decision from a long time ago, but it's the one feature that really bugs me, because no other library behaves like that.

You don't resize often for games, but for desktop apps - I know, not the target market - it looks terrible.

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 8:44 pm
by BrotSagtMist
This is a you problem.
Works on all my test boxes, so whatever you see there, this is specific to your system and not löve.

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 9:16 pm
by dcuny
Does love.update run during resizing?
No.

As far as I can tell, no callback is executing during a resize.

I figured that maybe something wasn't callinglove.run[/i] during that time, so I rewrote love.run so it went into a loop instead of returning a function in hopes to stop that:

Code: Select all

	-- Main loop time.
	return function()
		-- Process events.
It just went into the loop there:

Code: Select all

	local dt = 0

	-- Main loop time.
	while true do
		-- Process events.
But that didn't work. It looks like the issue is with love.event.pump(). :o:

This seems to confirm that it looks like it's an issue with SD_PumpEvent:.
If you are using a single thread, setting up an event watcher using SDL_AddEventWatch is not enough. This is because SDL_PumpEvents (which is called directly or indirectly by sdl) will not return until resizing is done, effectively blocking your thread.
There's a work-around, but it requires more knowledge about SDL than I've got, which at the moment is about zero.

Hrm... in the source code in wrap_Window.cpp, it looks like message boxes and file dialogs are exposed. But I don't know how to get to them from Love2D. They would sure be nice to have, instead of having to write a cross-platform file dialog myself in LFS. :brows:

Re: Black area while resizing window

Posted: Fri Jan 31, 2025 10:44 pm
by dcuny
BrotSagtMist wrote: Fri Jan 31, 2025 8:44 pm This is a you problem.
Works on all my test boxes, so whatever you see there, this is specific to your system and not löve.
It's not specific to my machine - I've run this on multiple Windows machines for years, and have always seen this behavior.

Here's a minimal program:

Code: Select all

function love.load()
   love.window.setMode( 100, 100, {resizable=true, borderless=false})
end

function love.draw()
  love.graphics.clear({0,1,0})
end
Running Love v11.5 on Windows 11, here's what I see when I resize the window:

Image

Re: Black area while resizing window

Posted: Sat Feb 01, 2025 12:09 am
by togFox
I think Brot is a Linux man.

Re: Black area while resizing window

Posted: Sat Feb 01, 2025 12:34 am
by dcuny
I've logged this into the LOVE GitHub.