我正在用SFML / C ++ / Code :: blocks编写一个简单的游戏。我写了一个简单的“ dev-console”,它基本上以转角fps,位置,逻辑/图形循环数等打印出来。 一切正常,直到我将其隐藏为止,然后fps从60(最大受阻)下降到大约15。为什么禁用写入功能会导致fps下降太多? (不应该禁用它来加快速度吗?)
声明:
tm = t.asMilliseconds();
fps += 1000/tm;
if (console == true)
{
consoletxt.setString("Last loop time: " + doubleToString(tm));
consoletxt.setPosition(0,0);
window.draw(consoletxt);
consoletxt.setString("Fps: " + intToString(1000/tm) + " Average fps: " + intToString(fps/logicLoops));
consoletxt.setPosition(0,15);
window.draw(consoletxt);
consoletxt.setString("objects[0].x: " + doubleToString(objects[0].x));
consoletxt.setPosition(0,30);
window.draw(consoletxt);
consoletxt.setString("objects[0].y: " + doubleToString(objects[0].y));
consoletxt.setPosition(0,45);
window.draw(consoletxt);
consoletxt.setString("Angle radians/degrees: " + doubleToString(cam_angle) + " | " + intToString((int)(cam_angle*180/pi)));
consoletxt.setPosition(0,60);
window.draw(consoletxt);
consoletxt.setString("Logical Loops: " + doubleToString(logicLoops) + " Graphics loops: " + doubleToString(graphicsLoops) + " Difference: " + doubleToString(logicLoops - graphicsLoops - 1));
consoletxt.setPosition(0,75);
window.draw(consoletxt);
consoletxt.setString("Variable test: " + doubleToString(cos(cam_angle*180/3.1415)));
consoletxt.setPosition(0,585);
//window.draw(consoletxt);
}
以下代码:切换控制台= false时; fps从60降至15
{{1}}