SFML community forums

Help => Window => Topic started by: Daevius on March 15, 2008, 09:33:42 pm

Title: Display() is decreasing my FPS dramatically
Post by: Daevius on March 15, 2008, 09:33:42 pm
Hi,

As the title says. I have a FPS of only 64 with some light-weight drawings with OpenGL. I did some experimenting, it seems that Display takes all time, when I remove that function I get a huge FPS. I turned VSync on and off, but didn't make any difference.

Do I HAVE to call Display if I only use OpenGL output? What else do I wrong?

Thanks
Title: Display() is decreasing my FPS dramatically
Post by: TTK-Bandit on March 15, 2008, 11:08:07 pm
are you sure you dont call it twice ? if I remove the call to Display, then nothing is drawn.

I noticed this fps bug too, although my fps calculation said it was 62fps.
I found out it was a call to sleep I did, it seems that no matter how small the value is you pass to Sleep, you always sleep for at least 16ms.

edit from msdn (http://msdn2.microsoft.com/en-us/library/ms686298%28VS.85%29.aspx) :
Quote
The system clock "ticks" at a constant rate. If dwMilliseconds is less than the resolution of the system clock, the thread may sleep for less than the specified length of time. If dwMilliseconds is greater than one tick but less than two, the wait can be anywhere between one and two ticks, and so on.
Title: Display() is decreasing my FPS dramatically
Post by: Laurent on March 16, 2008, 05:27:54 am
62 FPS, 64 FPS... seems like your driver has v-sync turned on. Make sure it's either "turned off" or "controlled by application" in your graphics card driver control panel.
Title: Display() is decreasing my FPS dramatically
Post by: Daevius on March 16, 2008, 11:13:48 am
Okay this is weird.

When I restarted my computer, it was suddenly much faster (perhaps I had some memory leaks with the testing before...?). Anyways, I have an FPS of 500 now ^^.

Also, the sleep improves FPS yes, but then I get a CPU of 100%. So I always sleep at least 1ms (even if that is ~16ms...can't help that) per display loop.

Thanks anyways...still I wonder why it was so slow yesterday...
Title: Display() is decreasing my FPS dramatically
Post by: TTK-Bandit on March 16, 2008, 11:21:39 am
laurent no im sure that vsync is off, besides I have a crt with 100hz, so it should be on 100 then, not  62.
Title: Display() is decreasing my FPS dramatically
Post by: Daevius on March 16, 2008, 01:42:04 pm
Quote from: "TTK-Bandit"
laurent no im sure that vsync is off, besides I have a crt with 100hz, so it should be on 100 then, not  62.


Yes, I'm sure my vsync was turned off either and my tft refresh rate is 75, so it should be ~75 instead of ~64.
Title: Display() is decreasing my FPS dramatically
Post by: TTK-Bandit on March 18, 2008, 12:06:07 am
found a solution:
call
timeBeginPeriod( 1 );
at the beginning of the main function and
timeEndPeriod( 1 );
at the end, they need to be in the main function, if you put them in the constructor/destructor of a global object it won't work.