using visual studio 2015 and SFML . relevant code:

sf::Font font;
sf::Text text;
text.setString("hello ");

It doesn't display the text. I put a breakpoint, the font gets the correct value. but the text's string stays empty. for the main window I get: + _mainWindow sf::RenderWindow

Can anybody help?


  • \$\begingroup\$ Could you share some code around this. Is this in a method? A class? Could you show how it is called? How is _mainWindow actually passed to it? \$\endgroup\$ – Tyyppi_77 Feb 26 '17 at 10:44

If your font goes out of scope, the text will not be able to display. SFML fonts need to stay for the scope of the text that uses them. (I can't tell very much because I don't have surrounding code, however).

| improve this answer | |

Are you calling _mainWindow.clear(); before _mainWindow.draw() and _mainWindow.display(); after it ?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.