emptyExample running at 50fps in release mode

Hi,

I’ve been working on an app in Win7/VS2010/OF74 for a few months which has been running fine (60fps). But this week something strange must have happened, and the app can only run at 50 fps. I though it was something app related, but then I tested the ‘emptyExample’ app and this also only runs at 50fps.

Could this have something to do with the graphics card? I have a Nvidia Gforce GTX660, with the Nnvidia control panel application.

Extra info-

  • I have disabled vsync
  • Running the app in release mode
  • If i set the frame rate in setup to anything up to 90, application runs at 50fps. But if I set the frame rate to 91, app runs at 100fps.

Thanks,
Trent

After running a few more tests the ‘emptyExample’ now runs around 33fps when it’s supposed to be 60. Occasionally (only happened once or twice) when compiling it will run at 60. But after a few more compiles it goes back to 33. I’m still not sure if this is hardware or software related. I download OF0073 to run the same example - still runs at 33.

I also ran the threejs demo in the browser- http://threejs.org/examples/#webgl-animation-skinning but this runs fine at 60fps. So that might rule out graphics card issues?

Solved thanks to some help from a work colleague (Dave Towey). I noticed when I launched Chrome the OF app would return to 60fps, Dave suggested Chrome was resetting something on the OS level and suggested the following which worked…

In setup add- timeBeginPeriod(1); and in exit add- timeEndPeriod(1); Also, just need to #include <Mmsystem.h> in your header as well.

Excellent thanks so much for solving that !

Hi trentbrooks,

I have the same FPS changing problem. I try to include timeBeginPeriod() by #include “Windows.h”, but no success.

Please can you give more details.

Thanks

Michael

Hi,

I’ve been experiencing with the emptyExample a little bit too, and here’s what I found out (windows 7 / Nvidia card)
Calling ofSetVerticalSync(true) or ofSetVerticalSync(false) is not chaning anything to the frame rate (at least in window mode) even when the nvidia driver is configured to follow the VSync app settings (I guess it’s not picking up the right settings or something weird along those lines)

On the other hand, if I force the vertical sync to off on the nvidia driver, it does make the Frame rate explode.

So maybe an approach to get the 60fps you want is : 1. Not set any frame rate in oF ; 2. Force the VSync on the driver of your card.

From my understanding of ofSetFrameRate and VSync, if you want your app to run at 60fps all the time and you’re not “lagging behind” it’s better to trust the driver of your video card to do the timing rather than asking a timer in windows to do it for you.

Hey @MikeFromMoon,

Sorry for the late reply. You need to include mmsystem.h. Below is the full code…

// in ofApp.h
#include <mmsystem.h>

class testApp : public ofBaseApp {
public:
    void exit(); // add this method
}


// in ofApp.cpp
void testApp::exit(){    
	timeEndPeriod(1);
}
void testApp::setup(){    
    ofSetFrameRate(60);
	timeBeginPeriod(1);
}
1 Like

Hi @trentbrooks ,

thank you very much, now I have a constant frame rate, but wired at 62.5 FPS instead of 60. I will dig more into it, when I have the time.

Thank you again

Michael

@MikeFromMoon, Exactly the same here… If the VSync on the Intel HD4000 is OFF and I ofSetFrameRate(60), it runs at a fixed 62.5fps. If VSync is turned ON, then it went to 58-59fps… what’s strange (62.5?)!

Also @trentbrooks I can reproduce the 32-33fps… All i need to do is to quit Google Chrome and then it drops… if I restart Chrome, then again i get back 59-62.5fps (depending on the VSync)…

Any Idea why this happens?

I saw this happening in the ofSketch workshop @ INST-INT on Saturday. When in front of Chrome (which is where ofSketch runs), the FPS was higher. When launched elsewhere, it was lower.