I’ve been working with SDL a while and have noticed
something I think might be peculiar (might be wrong on
this ). I was trying to get a picture to stay up
on the screen for 10 seconds before fading off, my
problem is, when I call SDL_Delay to do this, the
program cannot be moved at all, it literally freezes
(can’t move the window what so ever). I thought
SDL_Delay just allowed windows to get to do somet
stuff (basically froze any SDL functions at the time)
but it also freezes my program. I’m curious if this
is normal and if so, would I be better of using
SDL_GetTicks and just looping for 10 seconds? Thanks
in advance!
Doug__________________________________
Do you Yahoo!?
Jazz up your holiday email with celebrity designs. Learn more. http://celebrity.mail.yahoo.com
I’ve been working with SDL a while and have noticed
something I think might be peculiar (might be wrong on
this ). I was trying to get a picture to stay up
on the screen for 10 seconds before fading off, my
problem is, when I call SDL_Delay to do this, the
program cannot be moved at all, it literally freezes
(can’t move the window what so ever). I thought
SDL_Delay just allowed windows to get to do somet
stuff (basically froze any SDL functions at the time)
but it also freezes my program. I’m curious if this
is normal and if so, would I be better of using
SDL_GetTicks and just looping for 10 seconds? Thanks
in advance!
Doug
Yes. SDL_Delay is really just sleep(). It completely suspends the thread for that length of time.
If you use a busy loop instead, then that will use 100% CPU, and will still freeze if you don’t check events in the loop.
What you might do is set a timer to go in 10 seconds, and have the callback post a SDL_QUIT event.
Then you can just run a normal event loop using SDL_WaitEvent(), and you will get a SDL_QUIT event when it is time to close.
Alternatively, if you don’t want to depend on timer functionality, you can use something like this: