Now, I tried to change my code to use an SDL Timer. I added the
Uint32 and void *params parameters to updateGame and put this line
before my while loop:
SDL_AddTimer(30,updateGame,NULL);
Now, sometimes it works for a little, but it always ends up locking up
and Not Responding. It stops drawing, the screen turns white, and I
get an hourglass. What’s weird, I can still quit the game by hitting
escape, which is an event which calls Quit(0);
Now, I tried to change my code to use an SDL Timer. I added the
Uint32 and void *params parameters to updateGame and put this line
before my while loop:
SDL_AddTimer(30,updateGame,NULL);
Now, sometimes it works for a little, but it always ends up locking up
and Not Responding. It stops drawing, the screen turns white, and I
get an hourglass. What’s weird, I can still quit the game by hitting
escape, which is an event which calls Quit(0);
Now, I tried to change my code to use an SDL Timer. I added the
Uint32 and void *params parameters to updateGame and put this line
before my while loop:
SDL_AddTimer(30,updateGame,NULL);
Now, sometimes it works for a little, but it always ends up locking up
and Not Responding. It stops drawing, the screen turns white, and I
get an hourglass. What’s weird, I can still quit the game by hitting
escape, which is an event which calls Quit(0);
I’m not doing graphics in the timer though, the graphics is handled in
the main loop
You can’t call SDL_PollEvent() or SDL_PumpEvents() in the timer either.
Basically think that all input and graphics can only be done in the main
thread, and that the timer is in another thread and you’ll be fine. Note
that the timer may not actually be another thread on some systems, but that
should help you think about it.
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment
Well, can I use SDL to make a time-based input while also having a
processor-based graphics drawing loop? Is there any way to pull that
off without using separate threads? I guess I can have the timer flip
a boolean switch that the main loop checks for, like this:
Would this be an easy efficient way to handle this problem, or is
there a better way?
Thanks for responding BTW, you rock!
Jason GOn Tue, 30 Nov 2004 07:30:28 -0800, Sam Lantinga wrote:
I’m not doing graphics in the timer though, the graphics is handled in
the main loop
You can’t call SDL_PollEvent() or SDL_PumpEvents() in the timer either.
Basically think that all input and graphics can only be done in the main
thread, and that the timer is in another thread and you’ll be fine. Note
that the timer may not actually be another thread on some systems, but that
should help you think about it.
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment