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 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 |
Hi Matthieu
2015-04-09 17:54 GMT+02:00 Matthieu Lacaton <[hidden email]>:
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 |
In reply to this post by Matthieu
Hi Matthieu,
This is important: Binding SDL with Pharo will help Roassal to get better. Please, let us know how it goes Alexandre > On Apr 9, 2015, at 12:54 PM, Matthieu Lacaton <[hidden email]> wrote: > > 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 -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;. |
Hello, Thanks for your answers ! I have multiple remarks here : SDL_Renderer >> createTextureFromFile: file <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode> ^ self nbCall: #( SDL_Texture IMG_LoadTexture ( self , String file ) ) module: 'SDL_Image.dll' 2015-04-20 1:57 GMT+02:00 Alexandre Bergel <[hidden email]>: Hi Matthieu, Tata-SDLJeu.st (22K) Download Attachment |
In reply to this post by abergel
Alex
Just to make sure we are clear on this: pay attention NOBODY should directly use SDL. OSWindow is the API, SDL is a BACKEND. Athens is the API, CAIRO a BACKEND Stef Le 20/4/15 02:57, Alexandre Bergel a écrit : > Hi Matthieu, > > This is important: Binding SDL with Pharo will help Roassal to get better. > Please, let us know how it goes > > Alexandre > > >> On Apr 9, 2015, at 12:54 PM, Matthieu Lacaton <[hidden email]> wrote: >> >> 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 |
In reply to this post by Matthieu
2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
Yes.
|
In reply to this post by Matthieu
2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
On windows there is currently an issue if you use OSWindow instead of directly use SDL. If you create a window with OSWindow, (like in the SDL2Example>>osWindow) you will loose all "keystroke" events in the main pharo window. I don't know yet why this happens. nicolai |
In reply to this post by Matthieu
2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
What you could do, add a wait time in your event proccessing loop stop := false. [ stop ] whileFalse: [ .... 20 milliSeconds wait. ]. So, it does not constantly checks for new events. The better, cleaner way of course is, don't use your own sdl event processing loop, but use OSWindow (as soon as this is working :) ) best nicolai
|
In reply to this post by Nicolai Hess
Hello, We don’t lose all keystroke events, but they are replaced by keydown events. Merwan De : Nicolai Hess Envoyé : lundi 20 avril 2015 09:36 À : Any question about pharo is welcome; Esteban Lorenzano 2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
On windows there is currently an issue if you use OSWindow instead of directly use SDL. If you create a window with OSWindow, (like in the SDL2Example>>osWindow) you will loose all "keystroke" events in the main pharo window. I don't know yet why this happens. nicolai |
2015-04-20 13:13 GMT+02:00 <[hidden email]>:
Yes, KeyDown/KeyUp are working and instead of a keystroke event another keydown is sent. This is strange, I don't know exactly how the SDL event processing can influence the main window events. Maybe this has something to do how we look for new events in the SDL2DisplayPlugin. For me the call to SDL_PumpEvents looks unnecessary, maybe this is the cause? nicolai
|
Hi,
I just committed my prototype/experiment for windows with OSWindow, SDL2 and Athens. to check them: Gofer it smalltalkhubUser: 'Pharo' project: 'OSWindow'; package: 'OSWindow-Core'; package: 'OSWindow-SDL2'; package: 'OSWindow-SDL2-Canvases'; load. and check the examples at: OSSDLAthensWindow OSSDLMorphWindow cheers, Esteban
|
In reply to this post by stepharo
I see the point, but SDL seems to be pretty stable isn’t it?
Only two versions are reported on their website (1.2 and 2.0). Maybe it would be better to directly talk to SDL. Just wondering... Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
|
In reply to this post by Nicolai Hess
2015-04-20 13:55 GMT+02:00 Nicolai Hess <[hidden email]>:
So, I removed the call to SDL_PumpEvents, and now keystroke events are still working in the main window after opening an OSWindow. @Esteban Can you check if this is working on other platforms too.
|
In reply to this post by abergel
2015-04-20 16:56 GMT+02:00 Alexandre Bergel <[hidden email]>:
If you use SDL directly -> you will have to create your own event loop (and other stuff) If you use the OSWindow layer -> you will get a nice API that is already integrated with the main window / main window eventloop. |
In reply to this post by EstebanLM
2015-04-20 14:20 GMT+02:00 Esteban Lorenzano <[hidden email]>:
Great! Although the VM crashes sometimes (after closing the SDL-Window) And I know found out why the window is partly out of the screen (on Windows7, don't think this happens on linux/mac): If you open a SDL window with SDL createWindow: title x: 0 y: 0 .... The window opens at 0@0 but this is the upper left corner of the window rectangle *without* window decoration. If you open the window with SDL createWindow: title x: SDL_WINDOWPOS_UNDEFINED .... -> the full window is visible nicolai
|
Administrator
|
In reply to this post by EstebanLM
I got an error because my VM (via Launcher 0.2.4 - I can't upgrade due to a previously-reported error) doesn't have SDL2. I guess Launcher is using stable from 9/2014. How stable is VM latest? If I inject it into my current Launcher, will it be okay for general use?
Cheers,
Sean |
Administrator
|
That's odd... I opened the image with the latest VM and still got "Error: Failed to find SDL2 library" even though I can see libSDL2-2.0.0.dylib in the Plugins folder
Cheers,
Sean |
In reply to this post by EstebanLM
Cool work...!.. * The VM crashes on exampleTiger demo with Athens, resize and click close... sometimes in other scenario's. On Mon, Apr 20, 2015 at 5:50 PM, Esteban Lorenzano <[hidden email]> wrote:
crash.dmp (144K) Download Attachment |
Hello, Okay for me the problem was indeed that I had 64bits librairies. After recompiling them for 32bits it worked fine. Also when I use any of Esteban's examples even after I close the window I still have a SDL2 event loop processs active in the process browser. And sometimes (but i have not been able to reproduce it everytime) I have an Oswindow renderer loop staying active too. Le 21 avr. 2015 05:26, "S Krish" <[hidden email]> a écrit : |
In reply to this post by abergel
Le 20/4/15 17:56, Alexandre Bergel a
écrit :
I see the point, but SDL seems to be pretty stable isn’t it? This has nothing to do with stability of SDL. It has to do with layering software.
|
Free forum by Nabble | Edit this page |