SFML community forums

Help => General => Topic started by: Groogy on April 25, 2009, 12:24:54 am

Title: Weird thing with speed.
Post by: Groogy 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.
Title: Weird thing with speed.
Post by: Laurent on April 25, 2009, 12:26:50 am
Can you show us a minimal example that reproduces this problem?
Title: Weird thing with speed.
Post by: Groogy 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();
}