SFML community forums
Help => Window => Topic started by: Kipernal on September 16, 2011, 02:08:46 am
-
Essentially, if I create a RenderWindow and call its Display() function, it will cause the game to hang for 15 or 10 seconds for two out of every three calls. Here is the stripped-down code:
sf::RenderWindow App;
int main()
{
App.Create(sf::VideoMode(800, 600), "");
while (App.IsOpened())
{
double i = clock();
App.Display();
printf("%f\n",(clock()-i)/CLOCKS_PER_SEC);
}
}
and here is what it prints:
00.099000
00.002000
15.164000
10.096000
00.003000
15.142000
10.091000
00.002000
15.155000
10.098000
00.005000
15.148000
10.088000
00.003000
15.149000
10.089000
00.003000
15.173000
10.095000
00.004000
15.157000
10.092000
00.004000 (etc.)
I'm stumped here, and even stranger is that this issue just popped up recently, and I have no clue what caused it. I feel I should also mention that I don't have any issues with the pre-compiled examples, so it's not just an issue my computer has with RenderWindow. I'm still using SFML 1.6, not 2.0, if it helps, and I'm compiling using Visual Studio 2008. Any help would be greatly appreciated. (I assume this question goes here, right...?)
-
Try the same test but drawing the text to screen, writing to the console takes alot of time (computer wise). also use std::cout not printf, printf is for C not c++
-
Try the same test but drawing the text to screen, writing to the console takes alot of time (computer wise).
It does this regardless of whether or not I'm writing to the console. Either way I doubt doing so would take 15 seconds.
also use std::cout not printf, printf is for C not c++
Eh, it's just a bad habit, I guess. It doesn't really affect anything here, though.
-
You should try to add an event loop. The window behaves strangely when you don't give it a chance to process its events.
-
The event loop doesn't make a difference either; it was actually one of the things that I removed when I posted the stripped-down code.
-
try to set a framerate limit sf::Window::SetFramerateLimit before entering the main loop with a limit < 1000 (for example 120). and don't forget handle events.
That was the solution for me
-
That doesn't seem to be working either, unfortunately, but thank you.