SDL ttf

I have made pong game in sdl and i have tried to dynamically change the ttf font for example for incrementing score but it gives error , now i have option of blitting multiple images on screen like animation for score which is so tiring and tedious , is there a way around it

1
2
3
text = TTF_RenderText_Solid(font, "Hello World", color3);//instead of this 
string s ="1";
text = TTF_RenderText_Solid(font, s, color3);//why can't i try this or is there another way 
Last edited on
Don't know SDL, but the issue probably is that it doesn't know how to handle an std::string, it probably only knows how to handle C strings.

Edit: yep
SDL_Surface *TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg)

It wants a C string, so make your code be something like
1
2
const char* s = "1";
text = TTF_RenderText_Solid(font, s, color3);
Last edited on
Topic archived. No new replies allowed.