SFML community forums

Help => Graphics => Topic started by: Heero on October 19, 2007, 01:24:06 pm

Title: Display a value *Solved*
Post by: Heero on October 19, 2007, 01:24:06 pm
Is it possible to display a value in a window?
I want you display the mouse position in a window, but String can only handle std::strings.
Must I convert my float value to string to be able to display the text?

Heero

*Solved*

It now works, i use this code to display a value in the window.

Code: [Select]
_itoa(Sprite.GetRotation(), buffer, 10);
String.SetText(buffer);
Title: Display a value *Solved*
Post by: Laurent on October 20, 2007, 06:42:38 am
A better way in C++ is to use stringstreams :
Code: [Select]
#include <sstream>

std::ostringstream oss;
oss << Sprite.GetRotation();
String.SetText(oss.str());
Title: Display a value *Solved*
Post by: Heero on October 20, 2007, 02:44:31 pm
Thanks Laurent, thats looks much better :)