So. I'm fairly new to SFML and still learning c++.
And i'm curently in the process of making a simple Frame counter "FPS".
But i have run into a problem with Font loading.
When i do an ultra simple code like this.
// some text stuff
sf::Font font;
if (!font.loadFromFile("consola.ttf"))
{
// error...
}
sf::Text text;
text.setString("FPS: 0");
text.setFont(font);
text.setCharacterSize(12);
text.setColor(sf::Color::Black);
text.setStyle(sf::Text::Bold);
the program functions just fine.
But when i start to work with classes the program crashes at startup
Game.h
class Game
{
public:
Game();
void run();
private:
...
private:
...
sf::Font mFont;
sf::Text mText;
};
Game.cpp
Game::Game() : mWindow(sf::VideoMode(640, 480), "SFML Application"), mFont(), mText()
{
if (!mFont.loadFromFile("consola.ttf"))
{
/* Handle loading error */
};
mText.setString("FPS: 0");
mText.setFont(mFont);
mText.setCharacterSize(12);
mText.setColor(sf::Color::Black);
mText.setStyle(sf::Text::Bold);
}
Now i think it has something to do with the font as the problem persists in all cases except when i comment out mText.setFont(mFont);
I have tried other fonts including Times New Roman.
I'm currently reading up on debugging in code::blocks but i'm not getting anywhere.
If anyone can give a helping hand i would appreciate it a lot.
Thinks XorioZ