
I’ve decided that I should use SDL_ttf in my games. I had previously incorrectly thought that using it would lead to a performance hit and wrote my own printch and TextAt functions which with a fixed-with (monospaced) font saved as a bitmap worked ok.
However after reading up on this, I see that the main routine for outputting text returns a SDL_Surface. This is an in-ram structure.
SDL_Surface *TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_ColorĀ fg)
The significance of this is that you pre-render all text strings as much as possible then convert them to SDL_Textures which moves the structures into VRAM. That means those strings can be blitted as fast as my string method. It’s less flexible says when printing numbers, so it might make sense to output a monospaced font of digits in the desired colour and font sizeĀ (I call it a digitset) and prepare all the digit sets that you need. I’ll create a test program…
PS. This is my 100th blog entry! Here’s to the next 100….