No se quien habia posteado con problemas con TTF, es que me da pereza buscar, jeje, asi que aquí posteo un codigo para renderizar texto facilmente:
CSS2DLWriteText.h:
#include <SDL.h>
#include <SDL_ttf.h>
//Class header destinated to the text render in the videogame
class CSS2DLWriteText
{
public:
SDL_Surface *render;
SDL_Rect rect;
CSS2DLWriteText(char *text, SDL_Color color, SDL_Surface *dest, int x, int y, char *font, int size);
};
CSS2DLWriteText.cpp:
#include "CSS2DLWriteText.h"
//Class font file destinated to render text in a videogame
CSS2DLWriteText::CSS2DLWriteText(char *text, SDL_Color color, SDL_Surface *dest, int x, int y, char *tfont, int size)
{
TTF_Font *font = TTF_OpenFont(tfont, size);
render = TTF_RenderText_Blended(font, text, color);
rect.x = x;
rect.y = y;
rect.w = render->w;
rect.h = render->h;
SDL_BlitSurface(render, NULL, dest, &rect);
}
Luego en el main.cpp solo teneis que incluir CCS2DLWriteText.h y escribir donde querais algo como:
CSS2DLWriteText("El texto", un SDL_Color, la superficie de destino (normalmente screen), coordenada x, coordenada y, nombre de la fuente, por ej: "ariblk.ttf", tamaño de la fuente);
Tambien podeis crear un objeto de la forma CSS2DLWriteText nombre_de_tu_objeto para controlarlo posteriormente si hace falta.
Un saludo
PD: Aseguraros de tener instaladas las runtime de TrueType...