love.thread doesn't work with canvases?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Substance12
Prole
Posts: 19
Joined: Fri Dec 11, 2015 7:01 pm

love.thread doesn't work with canvases?

Post 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?
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.thread doesn't work with canvases?

Post 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.
Substance12
Prole
Posts: 19
Joined: Fri Dec 11, 2015 7:01 pm

Re: love.thread doesn't work with canvases?

Post by Substance12 »

Ah, I never noticed that. Thanks!
Substance12
Prole
Posts: 19
Joined: Fri Dec 11, 2015 7:01 pm

Re: love.thread doesn't work with canvases?

Post 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?
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: love.thread doesn't work with canvases?

Post 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.
Substance12
Prole
Posts: 19
Joined: Fri Dec 11, 2015 7:01 pm

Re: love.thread doesn't work with canvases?

Post 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
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: love.thread doesn't work with canvases?

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: love.thread doesn't work with canvases?

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Substance12
Prole
Posts: 19
Joined: Fri Dec 11, 2015 7:01 pm

Re: love.thread doesn't work with canvases?

Post by Substance12 »

Alright then, thanks for the help all.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests