Hi Matthieu 2015-04-09 17:54 GMT+02:00 Matthieu Lacaton <matthieu.laca...@gmail.com>:
> Hello everyone, > > I tried to use the SDL2 binding to Pharo to create a very basic 2D > application (just some sprites and events) and it worked great. > The issue I have is that when I start my application, as long as I have an > active SDL window, I can't use my Pharo image anymore (it freezes). > To solve this problem I tried opening my application in another thread by > doing so : > [ (MyApplication new) start. ] forkAt: Processor lowestPriority. (If I > don't chose a low priority it changes nothing) > > The problem is that even if it kind of works, it is really slow and it > slows my whole operating system as well (I use windows XP) > > How can I fork more efficiently or open a SDL window without losing > control of my image ? > > Thanks, > > Matthieu > This is a simple example based on the existing SDL2Example>>simpleDrawDisplay simpleDrawDisplay2 " self new simpleDrawDisplay2 " | window renderer texture | "Create the window and the renderer." SDL2 initVideo. window := SDL2 createWindow: 'Test Window' x: SDL_WINDOWPOS_UNDEFINED y: SDL_WINDOWPOS_UNDEFINED width: Display extent x height: Display extent y flags: SDL_WINDOW_SHOWN. renderer := window createDefaultRenderer. "Create the texture" texture := renderer createTextureFormat: SDL_PIXELFORMAT_XRGB8888 access: SDL_TEXTUREACCESS_STREAMING width: Display width height: Display height. 1000 timesRepeat: [ texture updateTexturePixels: Display bits pitch: Display width * 4. "Render" renderer copy: texture; present. 20 milliSeconds wait ]. "Quit" texture destroy. renderer destroy. window destroy Note, there is no call to SDL "delay" You can start this example with [SDL2Example simpleDrawDisplay2] fork Before you start this example, change the main window to half of your display screen, that way you can see both screens, the main vm and the "mirror" with SDL. nicolai