Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with SFML graphics loadFromFile  (Read 998 times)

0 Members and 1 Guest are viewing this topic.

PyZilla

  • Newbie
  • *
  • Posts: 2
    • View Profile
Problem with SFML graphics loadFromFile
« on: September 15, 2014, 09:25:35 pm »
Hi,

I am trying to display some text on my SFML window, but as the title says, there is an error with loadFromFile. I'm trying to load a font from my project directory. I checked, it's actually the working directory. Despite that, the load fails every time.

I would appreciate the help while I am still trying to figure this out.
#include <Windows.h>
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::Font font;
        sf::Text text;

        if(!font.loadFromFile("arial.tff")) {
                OutputDebugStringA("ERR0R\n");
        }

        text.setFont(font);
        text.setString("Success");
        text.setCharacterSize(20);
        text.setColor(sf::Color::White);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(text);
        window.display();
    }

    return 0;
}

Thank you for your help,

PyZilla
« Last Edit: September 15, 2014, 09:34:46 pm by eXpl0it3r »

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: Problem with SFML graphics loadFromFile
« Reply #1 on: September 15, 2014, 09:31:57 pm »
Stab in the dark, but is it because you have arial.tff instead of arial.ttf ?

PyZilla

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with SFML graphics loadFromFile
« Reply #2 on: September 15, 2014, 11:28:51 pm »
I feel like dying...

Thanks buddy!

PyZilla