Hi,
I'm new to SFML and a beginner with C++. I have the below code that I am interested about, because I'm really into making sure applications run as efficiently as possible.
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
//case sf::Event::KeyReleased:
// switch (event.key.code)
// {
// case sf::Keyboard::Return:
// if (isFullscreen == true)
// {
// window.create(sf::VideoMode(1366, 768), "Smaller Window", sf::Style::Default);
// isFullscreen = false;
// }
// else
// {
// window.create(sf::VideoMode(1920, 1080), "Bigger Window",sf::Style::Fullscreen);
// isFullscreen = true;
// }
// }
// break;
case sf::Event::Closed:
window.close();
break;
case sf::Event::MouseButtonPressed:
cout << "Mouse Pressed" << endl;
break;
}
}
}
important:without the code that is commented above, my application runs with max cpu usage of 2% and will go to 0% at idle.
with the code that is commented above, my application runs with a sporadic cpu usage between 4 and 8%. It will not go to 0% at idle.
This is very strange to me as a beginner. I feel like it should have virtually no affect on cpu usage when the user is not changing the window resolution.
Thoughts?