I’m currently learning to do output with TTF files and was wondering how i can output the font using variables with strings?
For example, i have the position of the mouseX and mouseY defined as Int.
I want to output a string like:
Mouse X: mouseX, Mouse Y: mouseY
This is where I output the text:
font_surface = TTF_RenderText_Solid(font_file,"MouseX: //need to add variable MouseY: //here too",font_color);
Does any one know the syntax to incorporate the variables to this function with the string ?
When I used SDL_ttf, I used
stringstreamto build my strings. You could also use sprintf but that’s generally discouraged in a C++ app..str()produces an STL string, and then.c_str()returns aconst char*to the guts of the STL string, which SDL, a pretty firmly C library, expects.