Page 1 of 1

Multple Windows (love.window)

Posted: Wed Mar 31, 2021 6:40 pm
by VEXED
Hey, possibly a bit of an oddball question. Is it possible with Love to create multiple widows per application?

The reason I ask is because I feel inspired to create a small GameMaker 6-8.0 style game development tool. It had multiple windows for different sub tools, like a sprite tool, object tool, etc. The goal is to design these tools in love, and have each accessed from the "main window" so to speak. Each would create a window instance when opened.

Thanks, if this isn't possible what would be some good alternatives for doing this (I would like to stick with Love)?

Re: Multple Windows (love.window)

Posted: Wed Mar 31, 2021 10:42 pm
by pgimeno
No, it's not possible with Löve (and I'm not sure but I think it's not possible on Windows for GL applications in general to open multiple windows). But you can use a GUI library that supports sub-windows (windows inside the main window). The best known is probably Löveframes, https://github.com/linux-man/LoveFrames but there are others like Slab or Gspöt.

Re: Multple Windows (love.window)

Posted: Wed Mar 31, 2021 11:46 pm
by zorg
pgimeno wrote: Wed Mar 31, 2021 10:42 pm No, it's not possible with Löve (and I'm not sure but I think it's not possible on Windows for GL applications in general to open multiple windows).
Some OpenGL-supporting emulators might beg to differ, but i'm not sure about the difference there, if one exists, to allow that kind of thing...

Another option you might have besides the GUI library is to have two löve apps running (with different code, probably), and have them communicate through some means, a local UDP connection, for instance.

Re: Multple Windows (love.window)

Posted: Thu Apr 01, 2021 2:06 pm
by VEXED
zorg wrote: Wed Mar 31, 2021 11:46 pm
pgimeno wrote: Wed Mar 31, 2021 10:42 pm No, it's not possible with Löve (and I'm not sure but I think it's not possible on Windows for GL applications in general to open multiple windows).
Some OpenGL-supporting emulators might beg to differ, but i'm not sure about the difference there, if one exists, to allow that kind of thing...

Another option you might have besides the GUI library is to have two löve apps running (with different code, probably), and have them communicate through some means, a local UDP connection, for instance.
While I will probably go with a GUI library I am curious about running multiple Love apps. How would I go about running another Love app from inside of a currently running Love app? Would this be a portable solution (across OS).

Re: Multple Windows (love.window)

Posted: Thu Apr 01, 2021 2:28 pm
by zorg
VEXED wrote: Thu Apr 01, 2021 2:06 pm While I will probably go with a GUI library I am curious about running multiple Love apps. How would I go about running another Love app from inside of a currently running Love app? Would this be a portable solution (across OS).
I did do this thing on the löve discord server as a test, it only uses löve's own modules and it's windows-only, but it might be editable to make it work across most supported OS-es... (iirc you'd only need to modify the non-fused part of the code)
no guarantees though ;)

CC0 / do whatever you want with the code - license.

Code: Select all

-- This will run in the second project we launch from this one.
local secondary_main_dot_lua = [[
function love.draw()
	love.graphics.rectangle('fill',10,10,100,100)
end
]]

function love.load(arg, morearg)
	-- No conf.lua, so we set the identity here.
	love.filesystem.setIdentity('AAAAA')

	-- Get the save directory path.
	local savpath = love.filesystem.getSaveDirectory()

	if love.filesystem.isFused() then
		-- FUSED

		-- Get the path to the fused executable.
		local exepath = love.filesystem.getSourceBaseDirectory()

		-- Copy non-fused love.exe to save directory from the fused executable. - Assume that you have a copy of love.exe inside your .love file... most inefficient
		love.filesystem.write('lovec.exe', love.filesystem.newFileData('lovec.exe'))

		-- Create secondary project's main.lua file in the save directory.
		love.filesystem.write('main.lua', secondary_main_dot_lua)

		-- Since we can mount the fused executable's path, we don't need to duplicate the dll-s, just copy from there. - the executable can't be copied itself, because it's fused with the project; it CAN NOT open another project due to that taking priority.
		local success = love.filesystem.mount(exepath, "temp")
		if not success then error("Could not mount source base dir.") end
		local files = love.filesystem.getDirectoryItems("temp")
		for i,file in ipairs(files) do
			if love.filesystem.isFile("temp/"..file) and file:match("^.+(%..+)$") == '.dll' then
				love.filesystem.write(file, love.filesystem.newFileData("temp/"..file))
			end
		end
		love.filesystem.unmount("temp")

		-- Needs an extra set of ""-s outside of the ones that go around the two paths!
		io.popen('""' .. savpath .. '/lovec.exe" "' .. savpath .. '/.""')
	else
		-- NOT FUSED

		-- Create secondary project's main.lua file in the save directory.
		love.filesystem.write('main.lua', secondary_main_dot_lua)

		-- We can use the internal path to the used executable to execute another project; no file copying needed.
		io.popen('""' .. morearg[-2] .. '" "' .. savpath .. '/.""')
	end
end

function love.draw()
	love.graphics.circle('fill',10,10,100)
end

Re: Multple Windows (love.window)

Posted: Thu Apr 01, 2021 8:21 pm
by VEXED
zorg wrote: Thu Apr 01, 2021 2:28 pm
I did do this thing on the löve discord server as a test, it only uses löve's own modules and it's windows-only, but it might be editable to make it work across most supported OS-es... (iirc you'd only need to modify the non-fused part of the code)
no guarantees though ;)

CC0 / do whatever you want with the code - license.
Thanks a bunch, all of this is greatly helpful when deciding how to go about my project.

Re: Multple Windows (love.window)

Posted: Fri Apr 02, 2021 10:47 am
by pgimeno
zorg wrote: Wed Mar 31, 2021 11:46 pm
pgimeno wrote: Wed Mar 31, 2021 10:42 pm No, it's not possible with Löve (and I'm not sure but I think it's not possible on Windows for GL applications in general to open multiple windows).
Some OpenGL-supporting emulators might beg to differ, but i'm not sure about the difference there, if one exists, to allow that kind of thing...
To clarify, I meant multiple GL windows per process. Of course any process can open multiple non-GL windows; Löve itself can do it (in particular love.window.showMessageBox).

On the other hand, it looks overkill to me to load another Löve instance just to show a window with controls. Even more so if it doesn't come with a conf.lua that disables most modules.

Re: Multple Windows (love.window)

Posted: Fri Apr 02, 2021 11:31 am
by zorg
pgimeno wrote: Fri Apr 02, 2021 10:47 am
zorg wrote: Wed Mar 31, 2021 11:46 pm
pgimeno wrote: Wed Mar 31, 2021 10:42 pm No, it's not possible with Löve (and I'm not sure but I think it's not possible on Windows for GL applications in general to open multiple windows).
Some OpenGL-supporting emulators might beg to differ, but i'm not sure about the difference there, if one exists, to allow that kind of thing...
To clarify, I meant multiple GL windows per process. Of course any process can open multiple non-GL windows; Löve itself can do it (in particular love.window.showMessageBox).
I mean, i'm pretty sure that one Wii U emulator was one process rendering into two OGL windows since they were physically separate windows and they rendered pretty complicated graphics... or maybe one buffer was blitted into two windows, if THAT is even possible, who knows...
pgimeno wrote: Fri Apr 02, 2021 10:47 am On the other hand, it looks overkill to me to load another Löve instance just to show a window with controls. Even more so if it doesn't come with a conf.lua that disables most modules.
Demo code, can be finetuned ¯\_(ツ)_/¯

Re: Multple Windows (love.window)

Posted: Fri Apr 23, 2021 9:14 pm
by tomxp411
VEXED wrote: Thu Apr 01, 2021 2:06 pm While I will probably go with a GUI library I am curious about running multiple Love apps. How would I go about running another Love app from inside of a currently running Love app? Would this be a portable solution (across OS).
I have a similar need - to use two windows to run my application. It's a presentation tool, and one window needs to fill a monitor. The other window is where the controls actually live.

In my case, what I decided to do was use UDP to communicate between the windows. The controller app just sends simple UDP packets to send commands to the main window. In my case, the main window is completely keyboard controlled, so the controller can just send messages that mimic the keyboard.

The nice thing about this solution is that I can actually run the app over two separate machines: the presenter can live on one computer and the controller can be a different computer on the same network. In the long run, I'll probably roll that into a digital signage system that will display announcements and upcoming events on monitors when we're not using them for live video.