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

Author Topic: Events and threads  (Read 2184 times)

0 Members and 2 Guests are viewing this topic.

Nitroreg

  • Newbie
  • *
  • Posts: 43
    • View Profile
Events and threads
« on: February 07, 2012, 06:27:18 pm »
I'm trying to handle events in a thread.
That seems not to work, "PollEvent" never returns true and "WaitEvent" never returns at all.

Is sf::Window thread-safe?
Can I call "Display" in the main thread and "PollEvent / WaitEvent" in a different thread?

Thanks

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Events and threads
« Reply #1 on: February 07, 2012, 06:35:10 pm »
http://www.sfml-dev.org/forum/viewtopic.php?t=3852

Please use the search function next time ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Nitroreg

  • Newbie
  • *
  • Posts: 43
    • View Profile
Events and threads
« Reply #2 on: February 07, 2012, 06:51:50 pm »
Thanks, events work in the main thread but graphics don't work if there are not in the main thread. When Display is called this error is printed on the output.
"Failed to activate the window's context"
The OpenGL context's version is 3.1

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Events and threads
« Reply #3 on: February 07, 2012, 09:28:39 pm »
Quote
events work in the main thread

No, they work in the thread where the window is created.

Quote
but graphics don't work if there are not in the main thread

Graphics work anywhere, as long as the window has first been deactivate in the thread where it was active.
Laurent Gomila - SFML developer

Nitroreg

  • Newbie
  • *
  • Posts: 43
    • View Profile
Events and threads
« Reply #4 on: February 08, 2012, 12:58:05 am »
It works now. Thanks a lot !

 

anything