martinium has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
acarrico has quit [Ping timeout: 240 seconds]
nisanharamati has quit [Quit: Connection closed for inactivity]
jemc has joined #ponylang
aturley_ has quit [Quit: aturley_]
acarrico has joined #ponylang
acarrico has quit [Ping timeout: 248 seconds]
_whitelogger has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
jemc has joined #ponylang
endformationage has quit [Quit: WeeChat 1.9.1]
dipin has quit [Quit: dipin]
user10032 has joined #ponylang
vaninwagen has joined #ponylang
samuell has joined #ponylang
jemc has quit [Ping timeout: 240 seconds]
user10032 has quit [Remote host closed the connection]
codec_ has joined #ponylang
<codec_>
Hi
<vaninwagen>
Ho
enilsen16 has joined #ponylang
enilsen16 has quit [Client Quit]
<codec_>
I am trying to do a simple game with Pony and SDL2 on windows am I am running into a couple of issues
<codec_>
some of them are design related on some them are technically
<vaninwagen>
just shoot, we'll try to help
<codec_>
The first is how to code the main loop
<codec_>
So far I thought of 3 ways
<vaninwagen>
i remember several guys having problems doing some UI because the libs they use require being called from the main thread
<codec_>
1- Do a while loop just like C/C++ would do
<codec_>
yeah I seems to run into that
<vaninwagen>
dammit
<codec_>
it was keeping it for the next questions :)
<codec_>
2- Use a timer
<codec_>
3- Have an actor calling a behavior on itself
<codec_>
The first approach seems problematic because pony use a cooperative threading model and as such the allocated memory created by the actor doing the while loop would never be garbage collected right ?
<vaninwagen>
codec_, afaik yes, this would also block 1 scheduler
<codec_>
So you would recommend going with the third approach?
<vaninwagen>
codec_ calling a behaviour is asynchronous so you might have some performance problems, as the next execution might not be executed right away but with some indeterminate delay
<vaninwagen>
i dont know if this is a problem in reality, never tried that
<codec_>
do you have numbers on delay? because if it is always < ~5ms it is fine for a small game
<codec_>
especially that I don't plan to use many actors so the scheduler would probably have not much actors to pick for running
<vaninwagen>
i guess then it is fine
<vaninwagen>
you could also do some batching and only re-execute the behaviour after each X loop iterations
<codec_>
yes there is probably a way to optimize further but I aim for keeping things really simple (at least at first)
<codec_>
so having dealt with the design issue, I can now bring the technicals one :)
<vaninwagen>
codec_ maybe, if you run your game with --ponythreads=1 you will always run from the same one, not 100% sure
<codec_>
To sum up, I have a main loop running with an actor calling a behavior on it self
<codec_>
When that happen I compute how much time have passed, move a square and poll the events
<codec_>
In release it seems to work fines, when I click the quit button the game quit
<codec_>
Yet compiling in Debug it does not work anymore
<codec_>
the square keep moving but for a reason it seems that I can't get the events
<codec_>
Do you have any idea of what could explain that and possibly how to fix it?
<vaninwagen>
codec_, no unfortunately not. maybe doublec has, as he played with SDL2 before
enilsen16 has joined #ponylang
<codec_>
It seems it was because I was using a struct instead of a class
<codec_>
what are the differences between a class and a struct?
Praetonus has joined #ponylang
_andre has joined #ponylang
<vaninwagen>
codec_, i'm sure Praetonus knows the differences between a pony class and a struct wrt calling C from pony
<codec_>
will ash him, thanks for the tip
enilsen16 has quit [Ping timeout: 258 seconds]
<Praetonus>
codec_: The difference is that a Pony struct doesn't have a type descriptor and therefore is ABI-compatible with a C struct with the same members
<Praetonus>
As a result, you can't use runtime polymorphism on a Pony struct (pattern matching, interface subtyping, etc.)
codec_ has quit [Ping timeout: 260 seconds]
enilsen16 has joined #ponylang
enilsen16 has quit [Ping timeout: 258 seconds]
enilsen16 has joined #ponylang
codec_ has joined #ponylang
<codec_>
Thanks Praetonus
<codec_>
Yet, I didn't understand what happened and why it ran fine in release but not in debug
<codec_>
Basically I have a C function that take a pointer to a C struct that is a union of different struct
<codec_>
I look at the rust wrapper for SDL2 and to interface it with this function they create a byte array of the length of the maximum struct in the union that happen to be 56 bytes
<codec_>
so I created a struct whose constructor created an array of such size so I can use it later on with the FFI function
<codec_>
It worked nicely in release but not in debug, and when I switched to a class instead of a struct in worked in both mode
<codec_>
and what confusses me in that when using a struct in debug the array seems to have a size of 0, just like the constructor was bypassed in some way
enilsen16 has quit [Read error: Connection reset by peer]
enilsen16 has joined #ponylang
<codec_>
I just put some print in the code and the constructor works fine in debug. The array inside the struct misteriously lose all its element in debug mode.
<codec_>
I wonder if it could be a bug in the code generation
<Praetonus>
Do you have some code demonstrating the problem codec_?
<codec_>
just my repo
<codec_>
I try in the playground but so far I cannot
<codec_>
by the way I found a fun bug. The pony compiler cannot generate an executable when the name would contains a space
<codec_>
@Praetonus I managed to reproduce the bug in a simpler example