SFML community forums
Help => Graphics => Topic started by: Zweistein on January 29, 2011, 05:28:40 pm
-
Hi,
Can i use sf::text with the normal Window? Its not a rendertarget. But how do i display text then?
lg
-
You can't use graphics classes with a sf::Window. Why don't you use a sf::RenderWindow?
-
Ok, i switched to renderwindow.
void Renderer2D::refresh()
{
std::cout << "Renderer2D::refresh()\n";
m_Engine->getWindow()->SaveGLStates();
sf::Font font;
if (!font.LoadFromFile("arial.ttf"))
return;
sf::Text text("Hello SFML", font, 50);
m_Engine->getWindow()->Draw(text);
m_Engine->getWindow()->RestoreGLStates();
};
However, this codes doesn t draw any text. (and i think my OpenGL perspective changed a bit...). The Font gets loaded. Where should the text appear?
-
It should appear at (0, 0), which is the top-left corner of the window -- unless you're using a custom view.
If it doesn't work, try with a very simple code first, and then when it works integrate it to your engine.
-
Default color of a Drawable is White(255, 255, 255).
Try to change it with
text.SetColor( sf::Color(0, 0, 0) );