Hello! I've finally released my EasyPianoGame on Steam:
https://store.steampowered.com/app/1126220/EasyPianoGame/I knew a problem about crashing in fullscreen style for a long time. I could not solve it at that moment and just used
sf::VideoMode::getFullscreenModes();
sf::RenderWindow window (FSModes[0], "", sf::Style::None);
and forgot afbout it.
After launch, some players started complaining about resolution problems and I decided to add resolution change feature.
So what is going on: When I create fullscreen window like this
sf::RenderWindow window(sf::VideoMode::getFullscreenModes()[0], "", sf::Style::Fullscreen);
it crashes. Not necessarily every time but often enough. And also some times the program crashes when the window closes. It happens when I run program on Intel GPU. In AMD GPU it works fine, but super slow and heavily loads the CPU, this is another problem.
Here is example code:
#include <SFML/Graphics.hpp>
int main()
{
auto FSModes = sf::VideoMode::getFullscreenModes();
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
window.setFramerateLimit(60);
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed)
switch (event.key.code)
{
case sf::Keyboard::Escape:
window.close();
break;
case sf::Keyboard::Num1:
window.create(FSModes[3], "", sf::Style::None);
break;
case sf::Keyboard::Num2:
window.create(FSModes[3], "", sf::Style::Default);
break;
case sf::Keyboard::Num3:
window.create(FSModes[3], "", sf::Style::Fullscreen);
break;
case sf::Keyboard::Num4:
window.create(FSModes[0], "", sf::Style::None);
break;
case sf::Keyboard::Num5:
window.create(FSModes[0], "", sf::Style::Fullscreen);
break;
}
if (event.type == sf::Event::MouseButtonPressed)
{
auto pos = sf::Mouse::getPosition();
shape.setPosition(pos.x - shape.getRadius(), pos.y - shape.getRadius());
}
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
Non full-screen window style switches work fine, but when you switch to full-screen style, with a probability of 50% it will crash. Debugger shows unhandled exception in ig7icd32.dll