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

Author Topic: [SOLVED]SFML text class not working  (Read 5667 times)

0 Members and 1 Guest are viewing this topic.

Atifhossain

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
[SOLVED]SFML text class not working
« on: March 14, 2013, 08:55:31 pm »
Here's the code


#include <SFML/Graphics.hpp>

int main ()
{
     sf::RenderWindow App (sf::VideoMode(447,340), "SFML App");

     sf::Text text("Hello");


    while (App.isOpen())
    {
        sf::Event Event;

        while (App.pollEvent(Event))
        {
            if (Event.type == sf::Event::Closed)
            App.close();

        App.clear();
        App.draw(text);
        App.display();
        }

     }

}

 

It says :
error : no matching function for call to 'sf::Text::Text(const char [6])'


« Last Edit: March 15, 2013, 12:03:09 pm by Atifhossain »

victorlevasseur

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: SFML text class not working
« Reply #1 on: March 14, 2013, 08:59:20 pm »
Hello,

If you use a more recent version of SFML thant the 2.0RC, you have to set a font when you initialize the sf::Text because there is no default font anymore.

kimci86

  • Full Member
  • ***
  • Posts: 123
    • View Profile
Re: SFML text class not working
« Reply #2 on: March 14, 2013, 10:02:58 pm »
Hi,
It makes me notice that the documentation for sf::Text needs an update.
The usage example is outdated. See this line.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML text class not working
« Reply #3 on: March 14, 2013, 10:50:16 pm »
Yes, and the explicit isn't necessary anymore ;)

Something I already thought about, is whether using the explicit keyword always (except for copy/move constructors) would be worth a try. It might at least help against changing constructor APIs where adapting explicit always is forgotten...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: SFML text class not working
« Reply #4 on: March 15, 2013, 08:12:34 am »
It's fixed, thanks for your feedback.
Laurent Gomila - SFML developer

Atifhossain

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: SFML text class not working
« Reply #5 on: March 15, 2013, 08:57:20 am »
Hey thanks everybody ! It 's working fine now  :D