Framerate randomly fluctuates between 60 and 30 fps (regardless of v-sync)

In my main.cpp I call ofSetFrameRate(60) and ofSetVerticalSync(false), but the framerate instantly plummets from 60 to 30 fps when I run the program. I’m in release mode (using Code Blocks), and I’ve even commented everything out of my draw loop…yet the problem remains.

The weird thing is that after I’ve been working for half an hour or so, the framerate suddenly locks at 60 and stays there until the next time I open on the project.

While not particularly informative, I’ve pinpointed the issue to the Sleep(waitMillis) call in ofAppGlutWindow.cpp. Even though the correct waitMillis is being passed in (16 millis for 60fps), the actual time it sleeps for is 32 millis.

I am thoroughly and utterly baffled by this…any ideas?

I’m guessing you’re on Win7 b/c of the Sleep vs sleep? This sounds like it might be some kind of weirdness between GLUT and your graphics card. You could you try a test (outside of OF) like this one maybe (if you’re on win) http://mycodelog.com/2010/04/16/fps/ and see if the framerate does something odd there. At least that would help narrow it down.

Good suggestion…I started a new Glut project in Code Blocks, put a “Sleep(16)” call in the idle function, and printed out the delta time between frames. It worked perfectly at first, but sure enough, when I opened it up twenty minutes later, the actual delta time was hovering between 31 and 32 millis (when I removed the Sleep(16) call, the delta time went back to 0-1 millis per frame).

So, definitely a glut-related problem.

I would attribute it to my graphics card like you mentioned, except updating my drivers had no effect, and I get the same fluctuating results when I run the application on my laptop (which runs Windows XP with a Nvidia Quadro FX 570M, as opposed to my desktop, which runs Windows 7 with a ATI Radeon HD 4800).

Aha! For anyone else using ATI Catalyst Control Center who experiences this problem, turning off “enable smooth video playback” under video settings seems to do the trick.

Hey thanks for posting that solution! That solved the same issue for me as well.

it was not directly the ‘enable smooth video playback’ but it had something to do with a video preset ‘using application default’

llarrythellama,

I’m seeing that same performance hit with OF in code::blocks in windows7 with an NVIDEA Quadro 6000 card.

Did you figure out how to get it working smoothly on your laptop with the NVIDEA card?

Thanks!

Jeremy