我试图让我的FPS显示在窗口标题,但我的程序只是没有它。
我FPS代码
void showFPS()
{
// Measure speed
double currentTime = glfwGetTime();
nbFrames++;
if ( currentTime - lastTime >= 1.0 ){ // If last cout was more than 1 sec ago
cout << 1000.0/double(nbFrames) << endl;
nbFrames = 0;
lastTime += 1.0;
}
}
我也希望它在这里的版本之后
window = glfwCreateWindow(640, 480, GAME_NAME " " VERSION " ", NULL, NULL);
但是我不能只叫void,我必须把它也转换成char,或者什么?
3条答案
按热度按时间rwqw0loc1#
请注意,
cout << 1000.0/double(nbFrames) << endl;
不会给予你“每秒帧数”(FPS),而是给你“每帧毫秒数”,如果你是60 fps,最有可能是16.666。xuo3flqw2#
你考虑过这样的事情吗?
new9mtju3#
总是有
stringstream
技巧:或者
boost.lexical_cast
。您可以使用
std::string::c_str()
来取得以null结尾的字串,以传入glfwSetWindowTitle()
。