0
\$\begingroup\$

using visual studio 2015 and SFML . relevant code:

sf::Font font;
font.loadFromFile("Arial.ttf");
sf::Text text;
text.setFont(font);
text.setString("hello ");
_mainWindow.draw(text); 

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?

thanks

\$\endgroup\$
  • \$\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
1
\$\begingroup\$

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 | |
\$\endgroup\$
-1
\$\begingroup\$

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

| improve this answer | |
\$\endgroup\$

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.