SDL2 and fork

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

SDL2 and fork

Matthieu
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
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
Hi Matthieu

2015-04-09 17:54 GMT+02:00 Matthieu Lacaton <[hidden email]>:
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
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

abergel
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
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Matthieu
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

2) But for the moment OSWindow uses SDL2 anyway so for experimentation purposes I will try to see what's wrong with my code.
The example you linked Nicolai is working indeed and this is more or less what I did too. I included my code with this e-mail so maybe you can have a better understanding (I am sorry but I didn't comment it :s). Note that for it to work you need to add the SDL_image library and all its plugins (for handling jpeg, png etc.) and add the following method to the image :

SDL_Renderer >> createTextureFromFile: file
    <primitive: #primitiveNativeCall module: #NativeBoostPlugin error: errorCode>
    ^ self
        nbCall: #( SDL_Texture IMG_LoadTexture ( self , String file ) )
        module: 'SDL_Image.dll'   

You can launch the game by executing "MyGame new startGame"

On my computer (which is probably not the fastest I must admit) running it with a fork slows the whole operating system.

3) Another problem I had lately : I tried to use Pharo with linux (ubuntu 14.04.2 LTS) and Pharo just can't find the SDL library.
I downloaded SDL source code and compiled it so i got the libSDL2-2.0.so.0.2.1 exactly as in the SDL2 class >> findSDL2 method.
I tried to put it everywhere (in the "shared" and "bin" folder of Pharo and even at the root. I tried in /usr/lib/, in /usr/lib32/, in /usr/lib/x86_64-linux-gnu etc. and Pharo can never find it.
Could it be that I compiled it for 64bits (my ubuntu is 64 bits) and Pharo does not support it so I should recompile it for 32 bits ?

Thanks you all !

Matthieu


2015-04-20 1:57 GMT+02:00 Alexandre Bergel <[hidden email]>:
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
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






Tata-SDLJeu.st (22K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

stepharo
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


Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
In reply to this post by Matthieu


2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
Hello,
...
Could it be that I compiled it for 64bits (my ubuntu is 64 bits) and Pharo does not support it so I should recompile it for 32 bits ?

Yes.

 

Thanks you all !

Matthieu


2015-04-20 1:57 GMT+02:00 Alexandre Bergel <[hidden email]>:
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
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
In reply to this post by Matthieu


2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
In reply to this post by Matthieu


2015-04-20 8:38 GMT+02:00 Matthieu Lacaton <[hidden email]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

On my computer (which is probably not the fastest I must admit) running it with a fork slows the whole operating system.


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



Matthieu


2015-04-20 1:57 GMT+02:00 Alexandre Bergel <[hidden email]>:
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
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

MerwanOuddane
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]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess


2015-04-20 13:13 GMT+02:00 <[hidden email]>:
Hello,
 
We don’t lose all keystroke events, but they are replaced by keydown events.

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

 
 
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]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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

Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

EstebanLM
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

On 20 Apr 2015, at 13:55, Nicolai Hess <[hidden email]> wrote:



2015-04-20 13:13 GMT+02:00 <[hidden email]>:
Hello,
 
We don’t lose all keystroke events, but they are replaced by keydown events.

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

 
 
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]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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


Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

abergel
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
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Apr 20, 2015, at 4:18 AM, stepharo <[hidden email]> wrote:

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



Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
In reply to this post by Nicolai Hess



2015-04-20 13:55 GMT+02:00 Nicolai Hess <[hidden email]>:


2015-04-20 13:13 GMT+02:00 <[hidden email]>:
Hello,
 
We don’t lose all keystroke events, but they are replaced by keydown events.

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?


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.




 

nicolai

 
 
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]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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


Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
In reply to this post by abergel


2015-04-20 16:56 GMT+02:00 Alexandre Bergel <[hidden email]>:
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

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.



Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Nicolai Hess
In reply to this post by EstebanLM

2015-04-20 14:20 GMT+02:00 Esteban Lorenzano <[hidden email]>:
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

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




 

cheers, 
Esteban

On 20 Apr 2015, at 13:55, Nicolai Hess <[hidden email]> wrote:



2015-04-20 13:13 GMT+02:00 <[hidden email]>:
Hello,
 
We don’t lose all keystroke events, but they are replaced by keydown events.

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

 
 
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]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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



Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Sean P. DeNigris
Administrator
In reply to this post by EstebanLM
EstebanLM wrote
I just committed my prototype/experiment for windows with OSWindow, SDL2 and Athens.
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
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Sean P. DeNigris
Administrator
Sean P. DeNigris wrote
VM latest
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
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

S Krish
In reply to this post by EstebanLM

Cool work...!..

* The x: 50 y: 50 initial point, on windows enables display of the title bar, otherwise hidden

* 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:
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

On 20 Apr 2015, at 13:55, Nicolai Hess <[hidden email]> wrote:



2015-04-20 13:13 GMT+02:00 <[hidden email]>:
Hello,
 
We don’t lose all keystroke events, but they are replaced by keydown events.

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

 
 
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]>:
Hello,

Thanks for your answers ! I have multiple remarks here :

1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.

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




crash.dmp (144K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

Matthieu

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 :
>
>
> Cool work...!..
>
> * The x: 50 y: 50 initial point, on windows enables display of the title bar, otherwise hidden
>
> * 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:
>>
>> 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
>>
>>> On 20 Apr 2015, at 13:55, Nicolai Hess <[hidden email]> wrote:
>>>
>>>
>>>
>>> 2015-04-20 13:13 GMT+02:00 <[hidden email]>:
>>>>
>>>> Hello,
>>>>  
>>>> We don’t lose all keystroke events, but they are replaced by keydown events.
>>>
>>>
>>> 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
>>>
>>>  
>>>>
>>>>  
>>>> 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]>:
>>>>>
>>>>> Hello,
>>>>>
>>>>> Thanks for your answers ! I have multiple remarks here :
>>>>>
>>>>> 1) I know that SDL2 should not be used "as is" in Pharo and I should use OSWindow instead, that's why I won't use SDL2 directly anymore.
>>>>
>>>>
>>>> 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
>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: SDL2 and fork

stepharo
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.

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
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.



On Apr 20, 2015, at 4:18 AM, stepharo <[hidden email]> wrote:

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




12