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

Author Topic: Drawing variables  (Read 3862 times)

0 Members and 1 Guest are viewing this topic.

Drraven

  • Newbie
  • *
  • Posts: 3
    • View Profile
Drawing variables
« 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.

Drektar

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Drawing variables
« Reply #1 on: December 14, 2010, 05:39:51 pm »
In the console or on a sf::RenderWindow?

Drraven

  • Newbie
  • *
  • Posts: 3
    • View Profile
Drawing variables
« Reply #2 on: December 14, 2010, 05:44:14 pm »
in RenderWindow

Drektar

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Drawing variables
« Reply #3 on: December 14, 2010, 06:21:21 pm »
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?

Laurent also give an example of a converter somewhere on the forum...

[Edit] I find it :
Code: [Select]
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;
    }
}

Drraven

  • Newbie
  • *
  • Posts: 3
    • View Profile
Drawing variables
« Reply #4 on: December 14, 2010, 08:51:34 pm »
I need to convert int to string and then just display this string.
Thanks Drektar

Silvah

  • Guest
Drawing variables
« Reply #5 on: December 14, 2010, 09:43:00 pm »
Quote from: "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.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Drawing variables
« Reply #6 on: December 14, 2010, 10:01:54 pm »
hum... maybe fr stands for french.  :roll:
http://www.sfml-dev.org/tutorials/1.6/graphics-fonts.php
SFML / OS X developer

 

anything