SFML community forums

Help => Window => Topic started by: rincewind on August 25, 2012, 05:00:14 pm

Title: issue with pollEvent in SFML 2.0
Post by: rincewind on August 25, 2012, 05:00:14 pm
Hello. I'm having an issue with pollEvent.

please check out my code

#include <SFML/Graphics.hpp>

int main()
{

    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!");
    sf::Text text("bla bla ");
    text.setPosition(100,100);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();
        window.draw(text);
        text.rotate(15);
        window.display();
    }

    return 0;
}
 

what it should be doing is just rotate some text really really fast, but when I move my mouse around the window, the text stops and nothing happens (also the text is rotating really laggy if the mouse is on the window). If I comment out the while loop, everything works as it should.

Also I noticed the same lags and slowdowns in the sample opengl.exe (included with sfml 2.0)

Does anyone know how to fix this?

(this is run on windows 7)
Title: Re: issue with pollEvent in SFML 2.0
Post by: Perde on August 25, 2012, 05:24:26 pm
Nevermind. I don't exactly know what happened. It was working properly after doing the change I suggested, but after resetting to your code again it continued to do so.

[edit]
Btw, when I thought that I could reproduce your problem, I was actually witnessing this:
http://en.sfml-dev.org/forums/index.php?topic=8971.msg60381#new (http://en.sfml-dev.org/forums/index.php?topic=8971.msg60381#new)
Title: Re: issue with pollEvent in SFML 2.0
Post by: eXpl0it3r on August 25, 2012, 06:03:30 pm
Well I do not have a problem with your code (also on Windows 7).
What graphics card do you use? Is it uptodate?
Do you have any application installed that could manipulate inputs or send messages to other applications?

Afaik we had already quite a few complaints where the event loop stalled the application, but I'm not sure if there ever was a solution... You could search the forum for it. ;)
Title: Re: issue with pollEvent in SFML 2.0
Post by: rincewind on August 26, 2012, 09:56:03 am
Looking through the forums I figured out that the problem is the joystick :\

I have a bluetooth joystick installed - I connect the ps3 joystick to the computer, and I think this causes the problem. If I change this

const sf::Time connectionRefreshDelay = sf::milliseconds(500);

to this

const sf::Time connectionRefreshDelay = sf::milliseconds(50000);

in the source, then everything works smoothly.