Questions around love.run

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.
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Questions around love.run

Post by Xii »

In what order does the engine call the callbacks? update before draw, presumably, but what about mousepressed, focus, etc.? When are these triggered? What if the main thread is in the middle of executing a function? What if the main thread is in the middle of accessing data that is also accessed from the callback?
Last edited by Xii on Sun Aug 16, 2020 10:31 pm, edited 2 times in total.
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Order of callbacks?

Post by sphyrth »

A similar question was answered.

Callbacks
Update
Draw

So, what ever you do (clicked on the mouse, move it, focus in/out) the data you intend to change there will generally be done first before updating the game. But now that we're at it. I also want to know a more precise order

Is it Window Events->Inputs->Update or is it something else?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Order of callbacks?

Post by grump »

There's probably no difference between "Window events" and "Input". Common sense says user input is processed in the window's message loop just as any other event.

Edit: on a second thought, I'm not sure I understand the question. Maybe you can clarify what you mean?
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Order of callbacks?

Post by sphyrth »

grump wrote: Thu Aug 13, 2020 11:52 pm Edit: on a second thought, I'm not sure I understand the question. Maybe you can clarify what you mean?
Supposed these happened:

1. I clicked on the "Maximize" button. - Does this count as "mousepressed"?
2. Window is Maximized.

I no longer included events like "love.event.quit" because I realized that you usually call them programatically.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Order of callbacks?

Post by grump »

sphyrth wrote: Fri Aug 14, 2020 10:19 am 1. I clicked on the "Maximize" button. - Does this count as "mousepressed"?
2. Window is Maximized.
Clicking on window borders, titles. and buttons does not generate mouse events. Alt+F4 does not generate key events either (except the keypressed event for the alt key ofc), even if you don't allow the window to close.
sphyrth
Party member
Posts: 260
Joined: Mon Jul 07, 2014 11:04 am
Contact:

Re: Order of callbacks?

Post by sphyrth »

Thanks! I'm indicating my question as solved. (I got too used to the "Like" system of Facebook that I didn't see the need to respond to answered questions. My bad. )
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Re: Order of callbacks?

Post by Xii »

Ah yes, I think the whole process is outlined on the wiki at love.run. You can, in fact, specify a custom main loop and order of calls. I like that.

Tangent question: love.graphics.present says it "will halt the program until ready" (when vsync is on). Does it halt all threads in the program or just the main one?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Order of callbacks?

Post by grump »

Xii wrote: Fri Aug 14, 2020 6:22 pm Tangent question: love.graphics.present says it "will halt the program until ready" (when vsync is on). Does it halt all threads in the program or just the main one?
That's more like a completely unrelated question.

Only the main thread is concerned with rendering, and only the main thread should call present. Other threads don't/can't wait for vsync.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Order of callbacks?

Post by zorg »

Only the main one.
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.
User avatar
Xii
Party member
Posts: 137
Joined: Thu Aug 13, 2020 9:09 pm
Contact:

Re: Questions around love.run

Post by Xii »

love.graphics.present says it "will halt the program until ready if necessary" (emphasis mine).
Supposing that vsync is on, and love.update + love.draw took more time than the screen's refresh rate allows (that is, we missed the vsync), does love.graphics.present halt the program? (until the next vsync)
In what situations will it consider it "necessary" to do so?
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 208 guests