SFML community forums
Help => Graphics => Topic started by: Drraven on December 14, 2010, 04:36:11 pm
-
Hi,
At the beginning of the English language I mean I know that he was not disappointment ;p
Can someone explain to me how can I display a variable of type int or float in sfml?
I will be grateful.
-
In the console or on a sf::RenderWindow?
-
in RenderWindow
-
You can display text on the screen with sf::String (sf::Text in SFML 2.0)
I suggest you to read the tuto:
http://www.sfml-dev.org/tutorials/1.6/graphics-fonts-fr.php
To display variable like a float it's the same thing but you have to convert your number into string before.
For this he have more than one method.
You can read that : How to convert a numeric type to a string? (http://www.codeguru.com/forum/showthread.php?s=&threadid=231056)
Laurent also give an example of a converter somewhere on the forum...
[Edit] I find it :namespace Converter
{
template <typename T>
std::string ToString(const T& i)
{
std::ostringstream stream;
stream << i;
return stream.str();
}
template <typename T>
T FromString(const std::string& str)
{
std::istringstream stream(str);
T tmp;
stream >> tmp;
return tmp;
}
}
-
I need to convert int to string and then just display this string.
Thanks Drektar
-
I suggest you to read the tuto:
http://www.sfml-dev.org/tutorials/1.6/graphics-fonts-fr.php
It's a tutorial? Looks rather like a totally random bunch of characters.
-
hum... maybe fr stands for french. :roll:
http://www.sfml-dev.org/tutorials/1.6/graphics-fonts.php