Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Rendertarget - sf::text  (Read 3314 times)

0 Members and 1 Guest are viewing this topic.

Zweistein

  • Newbie
  • *
  • Posts: 29
    • View Profile
Rendertarget - sf::text
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Rendertarget - sf::text
« Reply #1 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?
Laurent Gomila - SFML developer

Zweistein

  • Newbie
  • *
  • Posts: 29
    • View Profile
Rendertarget - sf::text
« Reply #2 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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Rendertarget - sf::text
« Reply #3 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.
Laurent Gomila - SFML developer

julen26

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
    • http://julen26.blogspot.com
Rendertarget - sf::text
« Reply #4 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) );

 

anything