[SDL] SDL_Event threading all backwards?

Charles McGarvey onefriedrice at brokenzipper.com
Mon Feb 25 20:59:56 PST 2008


This also confused me at first, but I ended up using Bob's Fast Events library which is faster (obviously) and does let you run your event loop in a different thread (as long as it's the same thread which initialized SDL).  Then in the main thread I just continuously render OpenGL.

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

By the way, there is an SDL initialization flag SDL_INIT_EVENTTHREAD, but I think it's only supported on Linux at the moment.  Anyway, look into the Fast Events library and see if it will do what you need.

Cheers,
Chaz
  ----- Original Message ----- 
  From: Mason Wheeler 
  To: sdl at lists.libsdl.org 
  Sent: Monday, February 25, 2008 9:24 PM
  Subject: [SDL] SDL_Event threading all backwards?


  I'm trying to implement SDL_Events in my game engine and running up against a brick wall.  Everything I read on the subject gives two mutually exclusive recommendations:

  1.  Managing SDL_Events has to be done from the application's main thread.
  2. The most efficient way to manage SDL_Events is with the SDL_WaitEvent function.

  This just won't work, because rendering also has to be done from the main thread.  I can't have my event loop stalling the rendering because the user isn't hitting any keys!  What kind of sense does it make to only have SDL_Events run on the main thread anyway, seeing as how the only sensible way to handle input in a multithreaded app using DirectX/OpenGL routines is in a different thread from the one doing the rendering?

  Frankly, I don't see the logic to this.  Is there any way around it?

  Mason Wheeler



------------------------------------------------------------------------------


  _______________________________________________
  SDL mailing list
  SDL at lists.libsdl.org
  http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080225/f213d31f/attachment-0008.htm>


More information about the SDL mailing list