My game is just a black background with white text, but, when the user changes resolution the GPU jumps to 100% and stays there. This issue happens on Windows, Linux, and Wine on Linux. It happens every time. I don't understand if I'm doing something wrong, or if SFML is.
The code for when the game starts up is this:
void TextInit()
{
font.loadFromFile("TextFont (FreeMono).otf");
font2.loadFromFile("UserInputFont (FreeMono).otf");
text = sf::Text();
text.setFont(font);
text.setPosition(0,0);
text.setFillColor(sf::Color(255,255,255,255));
text.setCharacterSize(20);
userInput = sf::Text(UserInputPre(), font2);
userInput.setPosition(0,1000);
userInput.setFillColor(sf::Color(255,255,255,255));
videoMode = sf::VideoMode(width, height);
if(doFullscreen)
window.create(videoMode, "Total Control", sf::Style::Fullscreen);
else
window.create(videoMode, "Total Control");
window.setMouseCursorVisible(true);
window.setMouseCursorGrabbed(false);
camera = sf::View(sf::FloatRect(0,0,width,height));
//window.setFramerateLimit(30);
window.setVerticalSyncEnabled(true);
window.setView(camera);
texture.loadFromFile("Background.png");
bg = sf::Sprite(texture);
bg.setPosition(0,1005);
bg.setScale(60, 5);
uiBoxHeight = bg.getPosition().y;
}
The code to change resolution is this:
void ChangeResolution(int size)
{
std::vector<sf::VideoMode> vms = sf::VideoMode::getFullscreenModes();
width = vms[size].width;
height = vms[size].height;
videoMode = sf::VideoMode(width, height, vms[size].bitsPerPixel);
if(doFullscreen)
window.create(videoMode, "Total Control", sf::Style::Fullscreen);
else
window.create(videoMode, "Total Control");
camera = sf::View(sf::FloatRect(0,0,width,height));
userInput.setPosition(0,height-userInput.getCharacterSize()-55);
bg.setPosition(0,height-userInput.getCharacterSize()-55);
}
Here is the draw code:
void TextManager()
{
bg.setColor(colours[inputBackgroundCol]);
window.clear(colours[backgroundCol]);
window.draw(text);
window.draw(bg);
window.draw(userInput);
window.display();
}