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 - chisser98

Pages: [1]
1
Window / Re: Using WindowHandle to get window input
« on: December 29, 2012, 02:23:27 am »
Thanks FRex, I just changed it to return a pointer to the sfml window.  Works fine now :)


2
Window / Using WindowHandle to get window input
« on: December 28, 2012, 04:30:14 pm »
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:

Quote
...
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):

Quote
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

Pages: [1]