SFML community forums

Help => Graphics => Topic started by: Atifhossain on March 14, 2013, 08:55:31 pm

Title: [SOLVED]SFML text class not working
Post by: Atifhossain 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])'


Title: Re: SFML text class not working
Post by: victorlevasseur 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.
Title: Re: SFML text class not working
Post by: kimci86 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. (https://github.com/SFML/SFML/blob/master/include/SFML/Graphics/Text.hpp#L340)
Title: Re: SFML text class not working
Post by: Nexus 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...
Title: Re: SFML text class not working
Post by: Laurent on March 15, 2013, 08:12:34 am
It's fixed, thanks for your feedback.
Title: Re: SFML text class not working
Post by: Atifhossain on March 15, 2013, 08:57:20 am
Hey thanks everybody ! It 's working fine now  :D