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.


Topics - mujina

Pages: [1]
1
General / Effect of no setFramerateLimit
« on: January 14, 2021, 05:42:49 pm »
Hi!

Can someone shed some light on how a game would behave when window.setFramerateLimit is not set?

I was running a very simple game and I accidentally commented out the line in which I was setting the framerate limit, and when I run it it appeared to be stuck. The first time it froze my entire screen (I had to Ctrl-Alt-F2, find the process and kill it. I'm on linux). The second time, the window appeared but that was frozen (the rest of my applications was not). The third time I run it, I didn't even see the window.

My program is something along these lines

RenderWindow window{{windowWidth, windowHeight}, "Title"};
// window.setFramerateLimit(120);
while(true){
    window.clear(Color::Black);
    Event event;
    int eventPerFrame {0};
    while(window.pollEvent(event)){
        if (event.type == Event::Closed) {
            window.close();
            break;
        }
    }
    if(Keyboard::isKeyPressed(Keyboard::Key::Escape)) break;
    // update logic here
    window.display();
}
 

Also, if I put some logging in the game loop, I don't see anything. It seems that it gets stuck at the event polling.

I'd like to understand if setFramerateLimit is mandatory and why apparently without that my program gets stuck at the polling.

[It's my first post here. Please let me know if I missed some rule of the etiquette or if I should do something differently].

Thank you!

Pages: [1]