- Código: Seleccionar todo
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
int main(int argc, char* argv[])
{
int done = 0;
SDL_Surface * pantalla;
SDL_Surface * tmp;
TTF_Font * font;
SDL_Event event;
SDL_Color Color2 = {200, 47, 215, 0};
SDL_Color Color3 = {0, 0, 255, 0};
SDL_Rect rect = {0, 100, 0, 0};
if (SDL_Init(SDL_INIT_VIDEO))
{
printf("No se puede iniciar SDL: %s\n", SDL_GetError());
return 1;
}
if (TTF_Init())
{
printf("No se puede iniciar TTF: %s\n", SDL_GetError());
return 1;
}
pantalla = SDL_SetVideoMode(320, 240, 16, 0);
font = TTF_OpenFont("font.ttf", 24);
rect.w = 20;
tmp = TTF_RenderText_Solid(font, "hola 1", Color2);
SDL_BlitSurface(tmp, NULL, pantalla, &rect);
rect.x = 120;
tmp = TTF_RenderText_Shaded(font, "hola 2", Color2, Color3);
SDL_BlitSurface(tmp, NULL, pantalla, &rect);
rect.x = 230;
tmp = TTF_RenderText_Blended(font, "hola 3", Color2);
SDL_BlitSurface(tmp, NULL, pantalla, &rect);
SDL_Flip(pantalla);
TTF_CloseFont(font);
while (! done)
{
while(SDL_PollEvent(&event)){
SDL_WaitEvent(& event);
if (event.type == SDL_KEYDOWN || event.type == SDL_QUIT)
done = 1;
}
}
return 0;
}
Gracias y un saludo.