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

Author Topic: Weird thing with speed.  (Read 2399 times)

0 Members and 1 Guest are viewing this topic.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Weird thing with speed.
« on: April 25, 2009, 12:24:54 am »
I noticed a thing. I got it printing out the elapsed time between frames.

And it first prints out between "Time: 0.0063...." to "Time: 0.0059...". Aight now comes the weird thing. When I grab the window, and move it and then releases it. This is decreased to 0.002 and sometimes even 0.001 and it continues at that speed for the rest of the lifetime of the application.

Is this a bug? Has it been noticed before?

I'm on Windows Vista when I tested this using the VC++ 2008 version of SFML.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Weird thing with speed.
« Reply #1 on: April 25, 2009, 12:26:50 am »
Can you show us a minimal example that reproduces this problem?
Laurent Gomila - SFML developer

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Weird thing with speed.
« Reply #2 on: April 25, 2009, 12:35:32 am »
Erhm don't know. Maybe.

Code: [Select]

void Application::EnterMainLoop(int argc, char * argv[]) {
// Will just display a background
GUI::MainMenu menu(this->appSender, this->mainWindow.GetWidth(), this->mainWindow.GetHeight());

// Here's where I start with the text to be put on display.
sf::String frame("", sf::Font::GetDefaultFont(), 15); char str[64]; frame.SetCenter(120, 0);
frame.SetPosition((float)this->mainWindow.GetWidth(), 2); frame.SetColor(sf::Color(0, 0, 255));
while(true) {
// Get events from SFML and turn it into signals
this->appSender.FetchEventsFromWindow(&this->mainWindow);
// Add a repaint signal to let know all the objects to be repainted on screen
this->appSender.AddSignal(RepaintSignal(&this->mainWindow));
// Send signals to all objects
this->appSender.SendSignals();

// Put "Time: x.xxxxxx" on the display.
sprintf_s(str, "Time: %.4g", this->mainWindow.GetFrameTime());
frame.SetText(str);
this->mainWindow.Draw(frame);

// Update display
this->mainWindow.Display();
}
}


This is my main loop. So dump something similar to the main function? The interesting thing is that the speed increases? If it's accurate. The thing is that it shouldn't be eliminated but taken advantage of. Somehow. Or maybe the timer is just off.


**EDIT**
Maybe this is enough?

Code: [Select]

sf::RenderWindow window(sf::VideoMode(800, 600), "Test");

// Create and position sf::String frame here
while(true) {
window.Clear();
sprintf_s(str, "Time: %.4g", window.GetFrameTime());
frame.SetText(str);
window.Draw(frame);
window.Display();
}
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

 

anything