Visual Studio 2013
sfml 2.1 [myself compiled]
sf::Text fps;
void gameWindow::setTextProperties(sf::Text &text, std::string string, unsigned char_size, sf::Color color, sf::Font font, sf::Vector2f position, float angle, sf::Uint32 style)
{
text.setString(string);
text.setCharacterSize(char_size);
text.setColor(color);
text.setFont(font);
text.setPosition(position);
text.setRotation(angle);
text.setStyle(style);
text.setOrigin(gameMath::setOrigin(text.getGlobalBounds()));
}
setTextProperties(fps, "", 12, sf::Color::Magenta, *gameFilesMgr::instance().getFont("font-orbitron-medium"), sf::Vector2f(2,2), 0, sf::Text::Regular);
fps.setString("string");
window.draw(fps);
it crashes when i call setTextProperties.
i had this problem even in sfml 2.0 .
font-orbitron-medium -> not the problem because same line is used in my npc's names
I have no idea where is the problem.
I think here it is:
*gameFilesMgr::instance().
Looks dangerous.
ps And use debug build.
I think here it is:
*gameFilesMgr::instance().
Looks dangerous.
ps And use debug build.
inline static gameFilesMgr &instance()
{
static gameFilesMgr i;
return i;
}
sf::Font *getFont(std::string);
And getFont returns non nullptr?
Try this:
sf::Font* fnt = gameFilesMgr::instance().getFont("font-orbitron-medium");
if (fnt)
{
setTextProperties(fps, "", 12, sf::Color::Magenta, *fnt, sf::Vector2f(2,2), 0, sf::Text::Regular);
}
ps And, and again, read this book http://www.gotw.ca/publications/c++cs.htm =)