Search code examples
c++sfml

SFML drawing text causes crash?


   #include <SFML/Graphics.hpp>

int main(){
    sf::RenderWindow app(sf::VideoMode(800, 600), "SFML window");

    sf::Text test;
    test.setString("Hello world");
    sf::Font font;
    font.loadFromFile("Monospace.ttf");
    test.setFont(font);

    // Start the game loop
    while (app.isOpen())
    {
        // Process events
        sf::Event event;
        while (app.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                app.close();
        }

        // Clear screen
        app.clear();

        // Draw the sprite
        app.draw(test);

        // Update the window
        app.display();
    }

    return EXIT_SUCCESS;
}

This is just a quick example I've thrown together. By all rights this should just work. But for some reason I just get a crash, everytime. If I comment out setFont, there is no crash. If I comment out the draw, there is no crash.

Running debug gives me the following error:

"Program received signal SIGSEGV, Segmentation fault.
In ?? () (C:\Windows\SysWOW64\ig4icd32.dll)"

I'd appreciate any thoughts as to why this is happening.


Solution

  • This actually turned out to be an issue with outdated hardware. I bought a new laptop and this was resolved.