Page 1 of 1
love.thread doesn't work with canvases?
Posted: Tue Jun 21, 2016 10:04 pm
by Substance12
I need to use love.thread to run another process, which is basically a copy of the world of the game. I'm using STI and Bump. But since the Lua process that love.threads runs has little to no features, I have to require the love modules I need, and had to supply the love.run function. All good so far. However, STI fails when loading a map giving me this error:
Code: Select all
Cannot create canvas: May not be supported by your OpenGL drivers.
My computer definitively supports canvases, since they work fine on the normal process, but they fail on a threaded process. Am I forgetting to supply something to the threaded .lua file?
Re: love.thread doesn't work with canvases?
Posted: Tue Jun 21, 2016 10:06 pm
by slime
The [wiki]love.thread[/wiki] wiki page has a notice near the top saying:
The love.graphics and love.window modules have several restrictions and therefore can only be used in the main thread.
In fact love.joystick, love.mouse, love.keyboard, and love.touch should also only be used from the main thread as well.
Re: love.thread doesn't work with canvases?
Posted: Tue Jun 21, 2016 10:20 pm
by Substance12
Ah, I never noticed that. Thanks!
Re: love.thread doesn't work with canvases?
Posted: Tue Jun 21, 2016 10:59 pm
by Substance12
Sorry for the double post, but i'm still confused. I still cannot get the threaded process to work like a somewhat normal Love2D game. I get errors with love.handlers, and many of the obvious solutions didn't work. Copying love.createHandlers() and executing it made it go crazy, and executing boot.lua and love.init() previous to everything gets me a bunch of errors about "arg" being nil.
How can I make the threaded process work like a normal Love2D game?
Re: love.thread doesn't work with canvases?
Posted: Wed Jun 22, 2016 1:17 am
by Tanner
New threads are in a separate memory space from the main thread. Any events you want to spawn will need to be sent through a Channel. A Channel is the only way to communicate between threads.
Re: love.thread doesn't work with canvases?
Posted: Wed Jun 22, 2016 1:38 am
by Substance12
Tanner wrote:New threads are in a separate memory space from the main thread. Any events you want to spawn will need to be sent through a Channel. A Channel is the only way to communicate between threads.
That's not what I need, the problem is that threaded .lua files act like plain .lua files and I need them to work like Love2D games
Re: love.thread doesn't work with canvases?
Posted: Wed Jun 22, 2016 3:25 am
by s-ol
Substance12 wrote:Tanner wrote:New threads are in a separate memory space from the main thread. Any events you want to spawn will need to be sent through a Channel. A Channel is the only way to communicate between threads.
That's not what I need, the problem is that threaded .lua files act like plain .lua files and I need them to work like Love2D games
Thats what he's saying, you can't . Any real interaction with the core löve api needs to happen in the main process. Also you need to require the different love modules by yourself in other threads.
Re: love.thread doesn't work with canvases?
Posted: Wed Jun 22, 2016 6:08 am
by zorg
Substance12 wrote:I get errors with love.handlers, and many of the obvious solutions didn't work. Copying love.createHandlers() and executing it made it go crazy, and executing boot.lua and love.init() previous to everything gets me a bunch of errors about "arg" being nil.
As s-ol said above me, you don't need to do any of that, just require 'love.<something>" where something is a löve module name like 'filesystem', but as slime said, 'window' and 'graphics' will probably not work... or at least, most of the functions won't; i haven't tested whether some would.
Re: love.thread doesn't work with canvases?
Posted: Wed Jun 22, 2016 2:31 pm
by Substance12
Alright then, thanks for the help all.