Re: [fpc-pascal] SDL 2.xx
On 02/03/2015 04:20 PM, Brian wrote: Threading SDL 2.03 is not particularly difficult if you observe the rules Nonetheless you need to take a lot of care when implementing any communication between multiple "Windows". -Michael ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SDL 2.xx
Threading SDL 2.03 is not particularly difficult if you observe the rules that a texture/renderer must reside in the same thread that created the window and (it appears) there is only one event (which as you mentioned makes sense) , and in my case the event handler is in a thread. SDL 2.03 has some very nice features which were not available in SDL 1.xx such as TEXTURE. I noticed quite a few posts on different forums asking how to do animation , and several posts mentioned that an early version of Doom had used SDL 1.xx to blit multiple surfaces to create the animation effects. One method of extremely fast animation is to use the example here as the basis. Although the example is not animation the underlying use of CPU memory and textures is 100% applicable to animation. http://www.programmersranch.com/2014/02/sdl2-pixel-drawing.html -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/SDL-2-xx-tp5720887p5720920.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SDL 2.xx
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 ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] SDL 2.xx
It appears (though I can't find any documentation / forums that actually states this) that SDL 2.03 only allows one event handler. 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. Brian -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/SDL-2-xx-tp5720887p5720900.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal