SFML community forums

Help => Graphics => Topic started by: Zweistein on January 29, 2011, 05:28:40 pm

Title: Rendertarget - sf::text
Post 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
Title: Rendertarget - sf::text
Post by: Laurent on January 29, 2011, 05:41:13 pm
You can't use graphics classes with a sf::Window. Why don't you use a sf::RenderWindow?
Title: Rendertarget - sf::text
Post by: Zweistein on January 29, 2011, 06:00:13 pm
Ok, i switched to renderwindow.

Code: [Select]
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?
Title: Rendertarget - sf::text
Post by: Laurent on January 29, 2011, 06:15:40 pm
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.
Title: Rendertarget - sf::text
Post by: julen26 on February 01, 2011, 06:36:15 pm
Default color of a Drawable is White(255, 255, 255).
Try to change it with
Code: [Select]
text.SetColor( sf::Color(0, 0, 0) );