I'm programming a simple game in SFML/C++/Code::blocks. I wrote a simple "dev-console" which basically prints out in the corner fps, position, number of logic/ graphics loops etc. Everything works fine until I hide it, then fps fall down from 60(blocked max) to around 15. Why disabling writing function causes so much fps drop? (shouldn't disabling it speed things up a little?)
Declarations:
sf::Text consoletxt;
sf::Font font;
if (!font.loadFromFile("Times_New_Roman.ttf"))
std::cout<<"Error loading font Times New Roman"<<std::endl;
consoletxt.setFont(font);
consoletxt.setFillColor(sf::Color(255,255,255,255));
consoletxt.setCharacterSize(14);
consoletxt.setOutlineColor(sf::Color(0,0,0,192));
consoletxt.setOutlineThickness(1);
bool console = true;
Code below: upon switching console = false; fps drops from 60 to 15
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);
}