Jump to content
  • Advertisement
Sign in to follow this  
Element of Power

Weird SDL events error...

This topic is 3606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I came across a weird error while experimenting with events. I've always used SDL_PollEvent in the past to get events, and I've never encountered any problems with it. But recently I heard somewhere that using SDL_WaitEvent is much quicker, so I tried using it. It detects events fine, it's just that nothing is rendered on the screen at all when I use it. Does anyone know why this is happening and how I can keep the renowned speed of WaitEvent while still being able to render on the screen?

Share this post


Link to post
Share on other sites
Advertisement
SDL_WaitEvent will wait until an event is available. Are you perhaps using SDL_WaitEvent in a while loop, like SDL_PollEvent usually is used? Then you will do nothing but wait for new events, so nothing will get rendered. I think you will need to run SDL_WaitEvent in another thread for it to work (but it must be the same thread that initialized the video mode).

Share this post


Link to post
Share on other sites
SDL_WaitEvent waits indefinitely for an event; it's blocking, so your program will stop until an event comes in.

Have you had problems with SDL_PollEvent being slow? Have you run it through a profiler? Calls to SDL_PollEvent shouldn't even amount to a small percentage of your program's execution time, so unless you know you're having problems with it, there's no point to optimizing it.

Share this post


Link to post
Share on other sites
Ok thanks for the info guys.

@Perost
I haven't looked at multi-threaded programming yet - it all sounds very confusing...

@kanato
No, I haven't had any problems with SDL_PollWait. It's just that it was suggested somewhere in Cone3D and I thought, if SDL_WaitEvent is quicker, then why not use it? Now I realise I can't use the same way i'd use SDL_WaitEvent, so I won't try to use it.

Again, thanks for the info.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!