Re: [Vala] How to use Game loop style with Glib main loop(for events)?




The first approach seems basic and very good, but I'm just wondering about asnc...
You've got me wrong there, I don't want to block glib main loop and wait until it finishes rendering, I just 
wonder about this behavior:
Suppose that user move forward when he press "w" in speed of 2(m)/(s) .
Now the traditional way is to get input, move character, rendering, and so go on...
But I want that the input won't be depended on FPS(when it's low, if it's high this problem is negligible), 
and it using dual buffering for thread safety.
So it means that I want an input thread(GLib main loop) that update the character position(and other stuff), 
and other thread for rendering.
The latter is my question: Rendering in other thread is safe, but is so the buffers switch? Should I take for 
this sync lock too?

Thanks,
Tal

Date: Fri, 5 Aug 2011 11:59:15 +0200
Subject: Re: [Vala] How to use Game loop style with Glib main loop(for events)?
From: taktaktaktaktaktaktaktaktaktak gmail com
To: tal_hd hotmail com
CC: vala-list gnome org

Thank you. If I get you right, this will block events until I finish drawing, but that is the purpose.
And is it possible to do it multi-threaded? In a way that input thread is different than drawing thread?

Well, the glib mainloop always needs to be on the thread where glib is
initialized.
I don't see a reason why that can't be synchronized with a separate
rendering thread, but it seems likely that having to synchronize
threads for every loop iteration will be slower than just running both
loops on the main thread.
                                          


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]