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

Author Topic: Odd behaviour managing events in a threaded renderwindow  (Read 2805 times)

0 Members and 1 Guest are viewing this topic.

chatran20

  • Newbie
  • *
  • Posts: 2
    • View Profile
Odd behaviour managing events in a threaded renderwindow
« on: July 02, 2011, 09:20:22 am »
This one is giving me a hard time. In my program I have a main window and subwindow that runs in a separate thread. The threaded window manages its own events independently of the main window.
It should work fine, and it seems to be able to process every event except the arrow keys!!
It's very strange because if I change the arrow keys to a WASD control it works fine. It seems that the threaded window it's unable to catch the arrow keys events, but I see no reason why. I even checked the code in SFML library that processes key events and I can't see any substantial difference between WASD keys events and arrow keys. So I'm stuck...   :(

My implementation it's something like this:


Code: [Select]

class MyClass : public sf::Thread
{
sf::RenderWindow *window;
sf::Event event;
        bool ok;

public:
MyClass();
~ MyClass();
void Handle_Event();
virtual void Run();
};
void MyClass::Run()
{
      while(ok)
      {
          Handle_Event();   //Handles key events
      }
}


Am I doing something wrong?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Odd behaviour managing events in a threaded renderwindow
« Reply #1 on: July 02, 2011, 10:24:39 am »
I think handling events in another thread doesn't work. Read this topic:
Can GetEvent or sf::Input be called from another thread?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

chatran20

  • Newbie
  • *
  • Posts: 2
    • View Profile
Odd behaviour managing events in a threaded renderwindow
« Reply #2 on: July 02, 2011, 09:02:05 pm »
Still it's very suspicious that it can handle every event fine except the arrow keys..  :shock:
Anyway, thanks!

 

anything