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

Author Topic: Dislpaying floats  (Read 2348 times)

0 Members and 1 Guest are viewing this topic.

Mr.123

  • Newbie
  • *
  • Posts: 2
    • View Profile
Dislpaying floats
« on: July 11, 2009, 10:41:55 pm »
Hi how would I go about being able to display a float?
For example if I wanted to draw out text in my rendered window saying my frames per second.

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
Dislpaying floats
« Reply #1 on: July 11, 2009, 11:11:15 pm »
You could do it like this assuming c++ being used:

Code: [Select]
#include <sstream>

sf::String fps;
std::stringstream ss;
ss << 1.f / renderWindow.GetFrameTime();
fps.SetText(ss.str());
fps.SetPosition(10, 10);
fps.SetColor(sf::Color::Black);
renderWindow.Draw(fps);

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
Dislpaying floats
« Reply #2 on: July 12, 2009, 12:41:32 am »
I think there's an entry in the wiki for this.  But yeah string stream should work well (you can also do a template function to take any stream capable object and insert it into a string).

Mr.123

  • Newbie
  • *
  • Posts: 2
    • View Profile
Dislpaying floats
« Reply #3 on: July 12, 2009, 12:49:32 am »
Sorry forgot to mention it is in c++. Thank you that works.

 

anything