Hey all,
I'm using SFML in a graphics engine as the window manager. In my game engine, I get the WindowHandle from the graphics engine, and then use it to create another SFML window in the game engine. I use this new window to handle events. (Basically, I wanted the graphics engine to handle graphics, and the game engine to handle input).
Unfortunately, the new window doesn't seem to be receiving any events. Also, if I call isOpen() on it, it returns false. In the graphics engine, I can loop through the events on the window and it works fine. However, if I don't loop through events in the graphics engine, and instead try to loop through events in the game engine, it doesn't seem to have any events there.
Here's what I call in my game engine:
...
sf::WindowHandle winHdl = window_->getWindowHandle(); // this gets and returns the sf::WindowHandle from my graphics engine
sf::Window sfmlWindow_(winHdl); // send the window handle to a new sfml window
...
In my 'handle events' method (which is called every time we go through the main game loop):
void Game::handleEvents() {
sf::Event event;
if (sfmlWindow_.isOpen() == true)
std::cout << "IS OPEN: " << (sfmlWindow_.isOpen() == true) << std::endl;
// while there are pending events...
while (sfmlWindow_.pollEvent(event)) {
std::cout << "event type: " << event.type << std::endl;
// check the type of the event...
switch (event.type) {
// window closed
case sf::Event::Closed:
//window.close();
break;
// key pressed
case sf::Event::KeyPressed:
//...
break;
// we don't process other types of events
default:
receiveKeyboardEvent(event);
receiveMouseEvent(event);
break;
}
}
}
Anyone have any idea what could be going on?
Cheers