Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
Window
»
Draw fps with window.draw
Print
Pages: [
1
]
Author
Topic: Draw fps with window.draw (Read 2034 times)
0 Members and 1 Guest are viewing this topic.
angdrw
Newbie
Posts: 2
Draw fps with window.draw
«
on:
March 11, 2016, 08:53:25 pm »
Hey i come up to a problem and i have no idea how to fix it, The problem is that i want to draw fps on the screen and it does so. But it seems that i does that multiple times . I think i have to reset the text.setString, It look like this:
http://postimg.org/image/jg2f2zxm7/
My code:
ostringstream ss;
sf::Text text;
text.setFont(font);
text.setCharacterSize(15);
text.setColor(sf::Color::Red);
text.setStyle(sf::Text::Bold);
text.setPosition(0,0);
//inside gameloop
//window.clear()
ss << "FPS: " << fps;
text.setString(ss.str())
window.draw(text);
//window.display()
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Draw fps with window.draw
«
Reply #1 on:
March 11, 2016, 09:01:53 pm »
ss.str("") to clear the ostringstream. But a better solution is to declare it only when you need it, inside the loop. This way you always start with a fresh stream, no need to deal with its previous content.
Logged
Laurent Gomila - SFML developer
angdrw
Newbie
Posts: 2
Re: Draw fps with window.draw
«
Reply #2 on:
March 11, 2016, 09:06:27 pm »
Thank you fixed the problem
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
Window
»
Draw fps with window.draw
anything