0
我使用OpenGL,Qt,C++編寫了3D模型顯示程序,但是我發現了一些奇怪的東西,即發佈模式版本中的FPS(每秒幀數)低於調試模式版本。現在我張貼他們的FPS:FPS:發佈模式版本低於調試
左邊是調試模式版本,右邊是發行模式版本:
我用它來計算FPS功能是
void displayFPS()
{
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTime = 0.0f; // This will hold the time from the last frame
float currentTime = GetTickCount() * 0.001f;
++framesPerSecond;
if(currentTime - lastTime > 1.0f)
{
framesPerSecond/=currentTime - lastTime;
char strFrameRate[256];
lastTime = currentTime;
sprintf_s(strFrameRate,256, "FPS : %f", framesPerSecond);
cout << strFrameRate << endl;
framesPerSecond = 0;
}
}
我不知道這怎麼會發生?不應該釋放模式比調試模式更快嗎?有人可以告訴我爲什麼嗎?
我覺得很難從給出的信息中分辨出來。 displayFPS()函數應該可以正常工作。 btw ..爲什麼你使用sprintf_s寫入fps到控制檯?而不是'cout <<「FPS:」<< framesPerSecond << endl;' – Dirk 2012-07-18 07:58:05
有時,vsync會導致有趣的效果。你有沒有嘗試禁用vsync?對於Nvidia GPU,您可以在Nvidia控制面板 - >管理3D設置 - >垂直同步:強制關閉。 – kroneml 2012-07-18 12:51:13