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

Author Topic: LShift and RSHIFT causes choppy framerate?  (Read 2578 times)

0 Members and 1 Guest are viewing this topic.

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
LShift and RSHIFT causes choppy framerate?
« on: August 21, 2013, 04:50:27 pm »
When running my app, whenever I press LSHIFT or RSHIFT, regardless of whether I am processing it or not within my event loop, the framerate becomes choppy-- randomly freezing for tenths of seconds and then speeding back up.

I'm using SFML 2.1

int main ( int argc, char *argv[] )
{
        // Create a new render-window
        sf::RenderWindow window(sf::VideoMode(800, 600), "AAAA");
        window.setFramerateLimit(60);

        sf::Clock clock;
    float lastTime = 0;

        sf::Texture texture;
        texture.loadFromFile("dot.png");
        sf::Sprite sprite;
        sprite.setTexture(texture);
        sprite.setPosition(500, 400);

        sf::Int32 direction = rand()%4+1;

        // The main loop
        while (window.isOpen())
        {
                // Event handling
                sf::Event Event;
                while (window.pollEvent(Event))
                {
                        if (Event.type == sf::Event::Closed)
                                window.close();
                }

                //      Data
                if(direction == 1)
                        sprite.setPosition(sprite.getPosition().x+1, sprite.getPosition().y);
                if(direction == 2)
                        sprite.setPosition(sprite.getPosition().x, sprite.getPosition().y+1);
                if(direction == 3)
                        sprite.setPosition(sprite.getPosition().x-1, sprite.getPosition().y);
                if(direction == 4)
                        sprite.setPosition(sprite.getPosition().x, sprite.getPosition().y-1);

                if(sprite.getPosition().x < 0 || sprite.getPosition().y < 0 || sprite.getPosition().x + 50 > window.getSize().x || sprite.getPosition().y + 50> window.getSize().y)
                {
                        sf::Int32 origDir = direction;
                        while(origDir == direction)
                                direction = rand()%4+1;
                }

                //      Clear & Draw window
                window.clear();
                window.draw(sprite);
                window.display();

                //      FPS output
                float currentTime = clock.getElapsedTime().asSeconds();
        float fps = 1.f / (currentTime - lastTime);
        lastTime = currentTime;

                std::cout << fps << "\n";
        }

        return 0;
}


Is there any reason for this? Any fix?

Thanks!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: LShift and RSHIFT causes choppy framerate?
« Reply #1 on: August 21, 2013, 05:17:15 pm »
I don't have that issue here...

What OS are you using? What compiler are you using? What graphics/keyboard/mouse driver are you using?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: LShift and RSHIFT causes choppy framerate?
« Reply #2 on: August 21, 2013, 06:07:28 pm »
Windows 7, VC++, Logitech K350 (http://www.adorama.com/LOK350WK.html)

My artist has the same keyboard and OS. Ill get him to test it when he returns from work.

I'd also like to note that it's not very noticeable unless you have a full game behind it (although the example I provided does replicate it to some degree). Oddly enough, games like Minecraft give me no problems when I press shift, which is why I think SFML is the problem.

I tested with all other keys and there are no problems.
« Last Edit: August 21, 2013, 06:10:59 pm by Jungletoe »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: LShift and RSHIFT causes choppy framerate?
« Reply #3 on: August 21, 2013, 07:39:37 pm »
Windows 7, VC++, Logitech K350 (http://www.adorama.com/LOK350WK.html)
Graphics card?

I'd also like to note that it's not very noticeable unless you have a full game behind it (although the example I provided does replicate it to some degree). Oddly enough, games like Minecraft give me no problems when I press shift, which is why I think SFML is the problem.
Well you might then have to adjust the measurement or the displaying of that, because currently I just see some running numbers and no noticeable difference when pressing shift or any other key. It just floats around 57-60 FPS...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: LShift and RSHIFT causes choppy framerate?
« Reply #4 on: August 21, 2013, 10:35:18 pm »
You can just add more sprites, although I still doubt you have the issue.

Intel(R) HD Graphics Family

Jungletoe

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: LShift and RSHIFT causes choppy framerate?
« Reply #5 on: August 21, 2013, 11:06:29 pm »
I just talked to my pixel artist and he doesn't have the problem. He's running win7 and uses my same keyboard. Not sure what his graphics card is.

 

anything