Jump to content
  • Advertisement
Sign in to follow this  

How to create a graphical timer in SDL_TTF?

This topic is 2822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I'm trying really hard to figure this out but I just don't know how to store a incrementing number into a string that I can use in SDL_TTF as like a graphical timer on screen.

TTF_RenderText_Blended( TimerFont,"Don't know what to do here ", MintGreenTestColor);

I tried creating const char incrementing number variable "ofc no luck"

const char timer = 0;
TTF_RenderText_Blended( TimerFont,timer, MintGreenTestColor);

I can't figure this out so I just want a way to basically put a incrementing number into a string so if anyone has any exact code samples or ideas that would be great to hear


Share this post

Link to post
Share on other sites
You need to write the number to a char buffer, then you can render it to a surface.

int time;
char buffer[128];
sprintf(buffer, "%d", time);
surface = TTF_RenderText_Blended(font, buffer, color);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!