Jump to content
  • Advertisement
Sign in to follow this  
vertex78

[SDL] Processing sdl events in a seperate thread

This topic is 3667 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

Advertisement
Well, on this page it says "You can only call this function in the thread that set the video mode.". It also says "Often the need for calls to SDL_PumpEvents is hidden from the user since SDL_PollEvent and SDL_WaitEvent implicitly call SDL_PumpEvents".

On this page it says "The video mode should be set by the Main Thread" - i.e. the thread that executes main().

So it appears the answer is no.

However, what you can do is have the main thread execute a SDL_WaitEvent() loop, with all the "heavy" processing occurring in other threads and all graphical calls made with inter-thread messages. This would require quite a bit of thought to work consistently, but it could work.

Can you describe what you wish to do?

Share this post


Link to post
Share on other sites
I originally had code written where I was polling for events in a seperate thread, and broadcasting them to listening objects (observer pattern), it works, but half the time the program would crash would xlib errors. I finally figured out that it was because I was polling for events in a seperate thread. So now I am polling for the events in the main thread and sending the event to my event thread to be processed. I guess I am stuck doing it this way.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!