Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - tchau83

Pages: [1]
1
Window / Problem using separate thread to handle events
« on: October 03, 2010, 01:18:12 pm »
I see.. I thought it could be done because in in the documentation for sf::Window::WaitEvent (SFML version 2), it is stated that "This function is typically used when you have a thread that is dedicated to events handling". Which I assume to mean a different thread for the same window.

2
Window / Problem using separate thread to handle events
« on: October 03, 2010, 06:40:14 am »
I'm coding a simulation program which displays the results in a window. The main thread handles the rendering while another thread handles the events. However the sf::Window function, global.app.WaitEvent() never returns, regardless of the event.

Code: [Select]
int main(){

   global.app.Create(...);
   sf::Thread thread(&getEvents);
   thread.Launch();

   while(not finished){
      ...
      glBegin()/glEnd()
      global.app.Display()
      ...
   }

   return;
}

void getEvents(){

   sf::Event event;
   while (global.app.WaitEvent(event)){

      if (event.Type == sf::Event::Closed)
         break;
   }
}


I tried adding global.app.SetActive() and sf::Context con to getEvents(), but it doesn't work either.

Can anyone help me get this to work? Thanks in advance


Side note:
I do not need event handling for the window, but the window will hang if it loses focus, even though the program is still running fine. So I think I need to clear the event stack periodically. I don't think I can put event handling in the main thread's loop, since each iteration takes several seconds to complete (the long period will probably trigger the window hang also). Also, this is for Windows XP. When running on Windows 7, the window hang problem doesn't occur even without event handling coded in.

Pages: [1]