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

Pages: [1]
1
Window / Re: Frame Rate/Periodic Lag Issues
« on: August 29, 2013, 12:31:58 pm »
Thank you! Your code improved the lag a lot.

I am still getting random spikes of about 30-40ms (double the usual 20ms frame time, but still less than it was before), but I've also compiled some other people's projects made in VS 2012 (which is what I'm using), and then I get the same problem with theirs too D:

Could I be missing some dll's from my computer/VS?

2
Window / Re: Frame Rate/Periodic Lag Issues
« on: August 28, 2013, 03:04:21 pm »
---Bump---

Have sent the release to my friends and they report the same problem, so I don't think it's my machine.
Have tried linking the libraries statically and dynamically, but still same problem

3
Window / Re: Frame Rate/Periodic Lag Issues
« on: August 25, 2013, 10:53:43 pm »
This is the source:

// Create the Window
 sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
 window.setVerticalSyncEnabled(true);

 sf::Clock clock;
 float lastTime = 0.0f;
 float currTime = 0.0f;
 // Run loop
 while (window.isOpen())
 {
   currTime = clock.getElapsedTime().asSeconds();
   if(currTime - lastTime >= 1.0f/30.0f) // 30FPS
   {
     // Check Events
     sf::Event event;
     while (window.pollEvent(event))
     {
       if (event.type == sf::Event::Closed)
         window.close();
     }
     // Game Logic
     if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
     {
       sf::Vector2i mousePos = sf::Mouse::getPosition(window);
       player2.SetPos(Vec((float)mousePos.x, (float)mousePos.y));
     }
     // Update Object positions and do collision checks
     world.Step(currTime - lastTime);
     std::cout << currTime - lastTime << "s" << std::endl;
     lastTime = currTime;
   }

   // Clear Window
   window.clear(sf::Color(185, 122, 87));
   // Draw everything here...
   window.draw( *( player.GetSprite() ) );
   window.draw( *( player2.GetSprite() ) );
   window.draw( *(wallLeft.GetSprite() ) );
   window.draw( *(wallRight.GetSprite() ) );
   window.draw( *(ground.GetSprite() ) );
   window.draw( *(ceiling.GetSprite() ) );
   // Display at Monitor's refresh rate
   window.display();
 }
 

4
Window / Frame Rate/Periodic Lag Issues
« on: August 25, 2013, 07:51:57 pm »
Hi everybody,

I'm new to SFML and new to the forum so sorry if I haven't posted correctly, but I'm having some issues with my C++ game.

My problem is that I'm getting inconsistent lag. I have searched around for solutions to frame rate issues and found people telling me to use Vsync, which I did but it didn't improve the situation. I've tried using an if statement inside my while(window.isOpen()) loop with sf::Clock.getTimeElapsed.asSeconds() > 1.0f/30.0f (my desired frame rate), and I've also tried to use the setFramerateLimit(30) function, but none of this seems to help.

The strange thing is, that I have tested the framerate by outputting the elapsed time to the console every frame, and the elapsed time is close to 0.033 for 9 or so frames, then it randomly increases to about 0.08, then back down again, and this cycle repeats, so the spike is about every half second.

Can anyone explain this weird behaviour? I am running this on a powerful machine, and my game has fairly efficient game logic, so I can't explain why these lag spikes occur. I didn't think including source code would be useful, but I can if anyone wants to take a look.
Any help would be greatly appreciated.

Thanks.  :)


Update:

I'm still at a loss, I've tried it even using basic minimal coding, and i'm still getting lagg spikes
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
        window.setVerticalSyncEnabled(true);
        sf::Clock clock;
        float currTime = 0.0f;
        float prevTime = 0.0f;

    while (window.isOpen())
    {
                        sf::Event event;
                        while (window.pollEvent(event))
                        {
                                if (event.type == sf::Event::Closed)
                                        window.close();
                        }
                        currTime = clock.getElapsedTime().asSeconds();
                        std::cout << currTime - prevTime << std::endl;
                        prevTime = currTime;
                        window.clear(sf::Color::Black);
                        window.display();
                        sf::sleep(sf::Time(sf::milliseconds(20)));
    }

    return 0;
}
 

I've got a screenshot of what the console outputs here, showing where the spikes occur:

Any help greatly appreciated :)

Pages: [1]
anything