Here is an example:
Here is the corresponding code:
TTF_Font *Sans = TTF_OpenFont("resources/fonts/lato/Lato-Semibold.ttf", 36);
if( Sans == NULL )
{
std::cout << "Failed to load font! SDL_ttf Error: " << TTF_GetError() << std::endl;
}
else
{
SDL_Color White = {255, 255, 255};
SDL_Surface *surfaceMessage = TTF_RenderText_Blended(Sans, "GAME OVER", White);
SDL_Texture *Message = SDL_CreateTextureFromSurface(renderer_, surfaceMessage);
SDL_Rect Message_rect;
Message_rect.x = 100;
Message_rect.y = 100;
Message_rect.w = 500;
Message_rect.h = 500;
SDL_RenderCopy(renderer_, Message, NULL, &Message_rect);
SDL_RenderPresent(renderer_);
}
(yes, I free the surface later)