Low framerate in Visual C++?


I was using Xcode on a mac for quite a long time, and everything was running beautifully. The current application I’m working on was running at almost 100 fps, which was really amazing. But then my boss told me to move it over to a pc, and I tried using Visual Studio express 2008. The program still runs fine, but our framerate went down to 30, both in debug and release versions. Has anyone experienced this loss in performance too? I don’t think it has anything to do with the processing power, because the pc I’m using is actually better than the mac, in terms of cpu. Does anyone know why this could happen?

Thank you very much,


Are you using any moviePlayers in your app? I don’t think they are threaded in Windows…which could slow things down.

In general there shouldn’t be any major difference between the platforms. What sometimes happens if you platform hop is that some bugs sometimes rear their ugly heads…bugs that were hidden or ignored before, or perhaps cross-platform bugs. Try profiling the app and see where the slow down is.

I suspect it’s a graphics card issue – what kind of graphics card does your pc have? It can make a huge difference in frame rate. Also valuable is vertical sync (usually off by default on mac) which could be turned on on the pc (and your frame rate might be above 30 fps).

ofDisableVerticalSync() and looking at the sync properties of your graphics card can help.

Are you using any moviePlayers in your app? I don’t think they are threaded in Windows…which could slow things down.

windows movie playing is using quicktime like on mac, so not sure what you mean…

I suggest commenting out draw() or update() to see what’s slow. Also, feel free to post any src / data folders for folks to check out.

take care,

I know the moviePlayer is using Quicktime in windows…but I thought I saw a thread mentioning that it was only threaded on OSX…but could be wrong.

My own experience is running ofMoviePlayer on windows after having it running on Linux with arturo’s GStreamer player and I got a significant slowdown…so I assumed it was a threading issue.

Thanks guys.

The graphics card on the pc is a NVIDIA GeForce 9600m GS with 1GB of memory, but I wouldn’t think that this would slow down the application.

Zach, you were right about the vertical sync being turned on by default. I disabled it and now I can get framerates that arent multiples of 30. I’m getting 50s and 40s which is already better.

just a comment for people, who are searching the ofDisableVerticalSync(). just use the ofSetVerticalSync( bool )

I seem to have a similar problem when compiling the exact same project in Visual Studio C++.

On the same machine, compiling a project with Codeblocks without any code optimizations I get a solid 100 fps. But when compiling with visual studio c++ with code optimizations i get a framerate of ± 16 fps.

This problem seems to arise when calling ofCurveVertex, this is really weird, since I use the same version of OF and the exact same code. Seems like the GNU compiler really beats the hell out of Visual Studio’s compiler…

i post a very small app that demonstrates this problem.

When calling ofCurveVertex(…) an x amount of times in the draw loop, visual studio makes my app drop framerate dramaticly, while codeblocks keeps my app running smoothly.


I never used VC++ but I remeber that someone posted here thar you had to absolutely make sure that you use release mode because debug mode would slow things very very down.
Just my 2 cents but as I said, I don’t use VC++ but maybe that helps



Hi snoogie,

Thanks for your reply.

Indeed when building a release some code optimization occurs, but still the difference between building with the GNU compiler from Codeblocks and the Visual C++ Express compiler is huge. Still the app runs ± 3 times faster when building it with GNU.

i know its been a while since the last reply, but just want to update on a similar experience i had with the issue:

in OSX the performance is consistent by default

in Windows (VS2008), i have to explicitly disable vertical sync to get consistent performance. otherwise it is *sometimes* consistent during a run, but during other runs it can vary quite a bit.

also, i discovered that:

  • can get a max of 250Hz in Windows (but the set framerate is not exactly the same. e.g. if I set it to 100, it actually does 110, etc. but as long as i turn off v-sync, the rate is constant).
  • in OSX the max framerate i get is 60Hz

this is for a simple app that keeps track of a trail of mouse positions in a deque and draws them as circles on screen.

system info:

windows - amd x3 720 (3GHz), 4GB DDR2, ATI 5770. v0.062, VS2008
mac - alu macbook. C2D 2.4 GHz, 2GB DDR3, Nvidia 9400m. v0.062, XCode 4

I found that code that uses lots of maths on CPU can run 2-5 times slower in Bootcamp/VC++ running on the same machine as XCode (with /O2 on both).

It turns out that VC++'s compiler doesn’t support auto loop vectorization, but GCC does
it’s a tech that automatically chooses SIMD extensions to perform multiple calculations in a single instruction (e.g. act on 4 floats at a time).

SIMD refers to the extra CPU instructions that you get with MMX/SSE/SSE2/SSE3/etc generally designed for computing graphics (although mostly that’s on your GPU nowadays).

That’s the only reason i can think of my (highly vectorizable loops) being significantly slower on PC (especially 4x slower). But that might not apply in your case.

You can access SIMD instructions in VC++ using Intrinsics (but I haven’t heard good things),and in VS2008 you can manually insert assembly pragmas into your code, but I don’t advise it! :slight_smile: