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

Author Topic: SFML Super slow on poll event  (Read 1470 times)

0 Members and 1 Guest are viewing this topic.

GSerum

  • Newbie
  • *
  • Posts: 8
    • View Profile
SFML Super slow on poll event
« on: May 17, 2018, 11:28:31 am »
Hey guys,
We're making a game for a project and we came across the following issue:

Currently we have the window poll event before all game logic, this works however the game logic is super slow, the player movement feels like it moves only twice a second.
When we move the window poll event behind the game logic call, it is super smooth, but we can no longer catch any events and thus cannot use keystrokes, closing the window etc.

For anyone wondering, the windowPointer is a pointer to the window (obviously), we pass this on because every player and object has its own update and render function and thus needs the window to be drawn.

while (window.isOpen()) {

          sf::Event event;
          while (window.pollEvent(event)) {
              if (event.type == Event::Closed) {
                  window.close();
              }
          }

        // Update all game logic.
        gameManager.update(windowPointer);

        // Clear window on each tick.
        window.clear();

        // Draw sand.
        window.draw(protoBackground);

        // Render all game entities.
        gameManager.render(windowPointer);

        // Display the window.
        window.display();
    }

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: SFML Super slow on poll event
« Reply #1 on: May 17, 2018, 02:30:50 pm »
Please provide a minimal and complete example.

Just because you found a way where it behaves differently doesn't mean that this is the cause, it might very well be a misunderstanding of using the SFML API. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything