[fpc-pascal] SDL 2.xx
Michael Schnell
mschnell at lumino.de
Tue Feb 3 10:13:43 CET 2015
On 02/02/2015 03:54 PM, Brian wrote:
> When the event handler (only one handler) is put in a thread , the event can
> be detected from different windows , those created in the thread and those
> created in the main thread (program) , by using SDL_GetWindowID() to get the
> identify of a window (WindowID) and later use it to recognize which window
> generated the event.
>
I suppose this will make the user software rather complicated.
The events assiciated with a window obviously are callbacks that run in
the thread that is associated to that window (which does make a lot of
sense).
I suppose you use TThread to generate the thread(s).
So you can find out where you are either by the the TThread "Self"
pointer provided by fpc (so most of the association is just automatic),
by the OS thread ID or by the SDL WindowID.
Threading problems will need to be cared for when trying to move any
information from one Thread (=Window) to another.
In Lazarus there always is only one "MainThread", associated to one
"MainWindow". As the LCL library in not thread save in itself, you can't
have multiple "Main" Windows in a program.
Without using the LCL, I suppose you can do such thing, but to generate
a decent GUI, you will need to implement an event queue for each
Window/Thread to allow user code to take advantage of the SDL functions
and Events.
-Michael
More information about the fpc-pascal
mailing list