Events

Hi, Im in the middle of writing a multiplatform frontier elite style game. My code previously ran fine under windows XP and SuSE linux 9.0. I Have tried to port it to my apple powerbook, and it compiles fine and even runs. The program doesnt actually respond though, it appears to be freezing when Im checking for events. I am using the fastevents library and net2. Both of which I know are quite popular. If anyone has any experience of using sdl, and in particular festevents under OS X (panther) then any suggestions would be greatly appreaciated.

What are fastevents? You could send me something to see if fastevents
will operate correctly on my system (to eliminate the possibility that
it’s a Mac OS X problem.)On Jul 28, 2004, at 9:57 AM, Matthew Simpson wrote:

Hi, Im in the middle of writing a multiplatform frontier elite style
game. My code previously ran fine under windows XP and SuSE linux
9.0. I Have tried to port it to my apple powerbook, and it compiles
fine and even runs. The program doesnt actually respond though, it
appears to be freezing when Im checking for events. I am using the
fastevents library and net2. Both of which I know are quite popular.
If anyone has any experience of using sdl, and in particular
festevents under OS X (panther) then any suggestions would be greatly
appreaciated.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny Viszneki

What are fastevents? You could send me something to see if fastevents
will operate correctly on my system (to eliminate the possibility that
it’s a Mac OS X problem.)

He means this:

http://www.gameprogrammer.com/fastevents/fastevents1.html

It’s basically a replacement for the event handling functions in SDL.
It gets rid of the 10ms delay in the WaitEvent function, and uses
threads to update/change the event queue. This makes the event
handling go faster.On Wed, 28 Jul 2004 10:57:19 -0400, Donny Viszneki wrote:

On Jul 28, 2004, at 9:57 AM, Matthew Simpson wrote:

Hi, Im in the middle of writing a multiplatform frontier elite style
game. My code previously ran fine under windows XP and SuSE linux
9.0. I Have tried to port it to my apple powerbook, and it compiles
fine and even runs. The program doesnt actually respond though, it
appears to be freezing when Im checking for events. I am using the
fastevents library and net2. Both of which I know are quite popular.
If anyone has any experience of using sdl, and in particular
festevents under OS X (panther) then any suggestions would be greatly
appreaciated.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny Viszneki

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Yeah I googled for it afterward and took some time to learn a bit about
it.

For the record, it may be failing because SDL threading doesn’t seem to
be working AT ALL under Mac OS X. I somehow forgot to post that to
the mailing list after reading about NET2 and fast events.On Jul 28, 2004, at 12:28 PM, Cosmin Stroe wrote:

On Wed, 28 Jul 2004 10:57:19 -0400, Donny Viszneki wrote:

What are fastevents? You could send me something to see if fastevents
will operate correctly on my system (to eliminate the possibility that
it’s a Mac OS X problem.)

He means this:

http://www.gameprogrammer.com/fastevents/fastevents1.html

It’s basically a replacement for the event handling functions in SDL.
It gets rid of the 10ms delay in the WaitEvent function, and uses
threads to update/change the event queue. This makes the event
handling go faster.

On Jul 28, 2004, at 9:57 AM, Matthew Simpson wrote:

Hi, Im in the middle of writing a multiplatform frontier elite style
game. My code previously ran fine under windows XP and SuSE linux
9.0. I Have tried to port it to my apple powerbook, and it compiles
fine and even runs. The program doesnt actually respond though, it
appears to be freezing when Im checking for events. I am using the
fastevents library and net2. Both of which I know are quite popular.
If anyone has any experience of using sdl, and in particular
festevents under OS X (panther) then any suggestions would be greatly
appreaciated.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny Viszneki

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny Viszneki

Hi, thanks for your help. Although Im not sure that threads arnt working under os x.
When loading my code up in gdb, the issue is that sdl never returns and event, every time the
event queue is checked its always empty, despite the fact that I am banging away on keys etc.
I have tried removing the fastevents/net2 code and replacing it with normal sdl api calls. the same
still applies. Threads seem to be working fine. When I check the log file my program creates, they all
execute and run fine. The one thing Im not sure about is whether or not sdl requires SDL_INIT_EVENTTHREAD
to be passed in the call to SDL_Init or not. Under windows it wont work with it, and under linux it doesnt work
without it. I cant seem to find any documentation for os x. If I dont pass SDL_INIT_EVENTTHREAD then the code
runs, but without any events appearing in the event queue. If I SDL_INIT_EVENTTHREAD then the application
quits with the dreaded SDL parachute deployed. Hope this gives anyone some ideas. Im fairly new to SDL, but
the code I had ran fine under linux and windows, so Its either an os x issue or an sdl issue. I cant quite decide which.From: Donny Viszneki smirk@thebuicksix.com
Reply-To: "A list for developers using the SDL library. (includes
SDL-announce)"
Date: Wed, 28 Jul 2004 21:03:14 -0400
To: "A list for developers using the SDL library. (includes
SDL-announce)"
Subject: Re: [SDL] events

Yeah I googled for it afterward and took some time to learn a bit about
it.

For the record, it may be failing because SDL threading doesn’t seem to
be working AT ALL under Mac OS X. I somehow forgot to post that to
the mailing list after reading about NET2 and fast events.

On Jul 28, 2004, at 12:28 PM, Cosmin Stroe wrote:

On Wed, 28 Jul 2004 10:57:19 -0400, Donny Viszneki wrote:

What are fastevents? You could send me something to see if fastevents
will operate correctly on my system (to eliminate the possibility that
it’s a Mac OS X problem.)

He means this:

http://www.gameprogrammer.com/fastevents/fastevents1.html

It’s basically a replacement for the event handling functions in SDL.
It gets rid of the 10ms delay in the WaitEvent function, and uses
threads to update/change the event queue.??This makes the event
handling go faster.

On Jul 28, 2004, at 9:57 AM, Matthew Simpson wrote:

Hi, Im in the middle of writing a multiplatform frontier elite style
game. My code previously ran fine under windows XP??and SuSE linux
9.0. I Have tried to port it to my apple powerbook, and it compiles
fine and even runs. The program doesnt actually respond though, it
appears to be freezing when Im checking for events. I am using the
fastevents library and net2. Both of which I know are quite popular.
If anyone has any experience of using sdl, and in particular
festevents under OS X (panther) then any suggestions would be greatly
appreaciated.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny Viszneki

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

  • Donny Viszneki

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Quoting Matthew Simpson :

Hi, thanks for your help. Although Im not sure that threads arnt working
under os x.
When loading my code up in gdb, the issue is that sdl never returns and
event, every time the
event queue is checked its always empty, despite the fact that I am banging
away on keys etc.

Are you checking the events in the original (main) thread? I have a feeling
that if you’re checking from another thread then you won’t get any events. But
I may well be talking nonsense, everyone feel free to jump in and correct me.

I am checking for events in the same thread that called SDL_init. Events are only checked
in this thread.On Thursday, July 29, 2004, at 02:40AM, Neil Brown wrote:

Quoting Matthew Simpson <@Matthew_Simpson>:

Hi, thanks for your help. Although Im not sure that threads arnt working
under os x.
When loading my code up in gdb, the issue is that sdl never returns and
event, every time the
event queue is checked its always empty, despite the fact that I am banging
away on keys etc.

Are you checking the events in the original (main) thread? I have a feeling
that if you’re checking from another thread then you won’t get any events. But
I may well be talking nonsense, everyone feel free to jump in and correct me.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Threads seem to be working fine.

Go into the SDL source code and find tests/threadwin.c (or something
similarly named.) Build it, and run it with the -threaded or -thread
option (I can’t remember which one.) On my system (10.3.4) it fails.

The one thing Im not sure about is whether or not sdl requires
SDL_INIT_EVENTTHREAD
to be passed in the call to SDL_Init or not.

This is not the first time there has been confusion about
SDL_INIT_EVENTTHREAD. AFAIK the last time it was mentioned, it was me,
theorizing that this flag adds mutex locking to the event queue to
allow for multiple threads to access the event queue safely. It seems
to crash on Mac OS X.

If I dont pass SDL_INIT_EVENTTHREAD then the code runs, but without
any events appearing in the event queue. If I SDL_INIT_EVENTTHREAD
then the application
quits with the dreaded SDL parachute deployed.

This seems to corroborate my theory, that is, if FastEvents accesses
the event queue from another thread, then it requires
SDL_INIT_EVENTTHREAD to work. And if you try using
SDL_INIT_EVENTTHREAD, then on Mac OS X, you get a crash.

I will probably spend some more time looking at the SDL source code to
see what causes the problem. If anyone can offer any insight concerning
general information about how SDL handles threading, I would be very
grateful (even though I won’t personally be threading my SDL
applications any time soon.)On Jul 29, 2004, at 5:36 AM, Matthew Simpson wrote:

Threads seem to be working fine.

Go into the SDL source code and find tests/threadwin.c (or something
similarly named.) Build it, and run it with the -threaded or -thread
option (I can’t remember which one.) On my system (10.3.4) it fails.

The one thing Im not sure about is whether or not sdl requires
SDL_INIT_EVENTTHREAD
to be passed in the call to SDL_Init or not.

This is not the first time there has been confusion about
SDL_INIT_EVENTTHREAD. AFAIK the last time it was mentioned, it was me,
theorizing that this flag adds mutex locking to the event queue to
allow for multiple threads to access the event queue safely.

No that is not what it does. It creates a thread which then polls the
OS for events. I recommend searching the SDL source for this flag and
then following it up from there; that part of the code isn’t hard to
understand, actually.

It seems to crash on Mac OS X.

The crash is easy to fix (a simple race condition); but the feature
still won’t work. Apparently you can only check the events from the
main thread, so using a dedicated thread for event handling won’t work.

If I dont pass SDL_INIT_EVENTTHREAD then the code runs, but without
any events appearing in the event queue. If I SDL_INIT_EVENTTHREAD
then the application
quits with the dreaded SDL parachute deployed.

This seems to corroborate my theory, that is, if FastEvents accesses
the event queue from another thread, then it requires
SDL_INIT_EVENTTHREAD to work. And if you try using
SDL_INIT_EVENTTHREAD, then on Mac OS X, you get a crash.

Your theory is wrong. In fact, from what I read here, it seems
FastEvents duplicates the behaviour of SDL_INIT_EVENTTHREAD, or at
least, does something similar: it spaws a thread to handle events.
However, even after fixing the crash you observe (it requires adding
one line to the quartz video backend), you still won’t see any events
at all. The Apple docs aren’t explicit on this, but from what I gather,
it appears that only the main thread can read the events from the OS.
Not 100% sure, though, I might investigate more once I have some spare
time on my hands.

I will probably spend some more time looking at the SDL source code to
see what causes the problem. If anyone can offer any insight
concerning general information about how SDL handles threading, I
would be very grateful (even though I won’t personally be threading my
SDL applications any time soon.)

There is not much to say about it, I’d say. The SDL threads are
basically a loose wrapper about the standard pthread calls (on Unices,
at least; of course on Windows etc. things are different).

Bye,

MaxAm 29.07.2004 um 17:34 schrieb Donny Viszneki:

On Jul 29, 2004, at 5:36 AM, Matthew Simpson wrote:

No that is not what it does. It creates a thread which then polls the
OS for events. I recommend searching the SDL source for this flag and
then following it up from there; that part of the code isn’t hard to
understand, actually.

Ah, no one responded to the post I made concerning what I thought
SDL_INIT_EVENTTHREAD, thank you for clearing that up.

It seems to crash on Mac OS X.

The crash is easy to fix (a simple race condition); but the feature
still won’t work. Apparently you can only check the events from the
main thread, so using a dedicated thread for event handling won’t
work.

Is this fixed in CVS?

I will probably spend some more time looking at the SDL source code
to see what causes the problem. If anyone can offer any insight
concerning general information about how SDL handles threading, I
would be very grateful (even though I won’t personally be threading
my SDL applications any time soon.)

There is not much to say about it, I’d say. The SDL threads are
basically a loose wrapper about the standard pthread calls (on Unices,
at least; of course on Windows etc. things are different).

Perhaps you were confused here. I wanted to look at the threading
portion of SDL because I thought threading on OS X was the problem. You
have said otherwise.On Jul 29, 2004, at 3:28 PM, Max Horn wrote: