#include <iostream>#include <SDL.h>#include <SDL_ttf.h>using namespace std;int main(int argc, char *argv[]){ SDL_Color bgcolor, fgcolor; SDL_Rect rectangulo; SDL_Surface *screen, *ttext; TTF_Font *fuente; const char texto[14] = "Hola Mundo..."; char msg[14]; SDL_Event event; int done = 0; if(SDL_Init(SDL_INIT_VIDEO) < 0){ cout << "No se pudo iniciar SDL: n" << SDL_GetError(); exit(1); } screen = SDL_SetVideoMode(640,480,24,SDL_HWSURFACE|SDL_DOUBLEBUF); if(screen == NULL){ cout << "No se puede iniciar el modo grafico: n" << SDL_GetError(); exit(1); } atexit(SDL_Quit); if(TTF_Init() < 0){ cout << "No se pudo iniciar SDL_ttf: n" << SDL_GetError(); return 1; } atexit(TTF_Quit); fuente = TTF_OpenFont("ariblk.ttf",20); fgcolor.r=200; fgcolor.g=200; fgcolor.b=10; bgcolor.r=255; bgcolor.g=0; bgcolor.b=0; sprintf(msg,"%s",texto); ttext = TTF_RenderText_Shaded(fuente,msg,fgcolor,bgcolor); rectangulo.y=100; rectangulo.x=100; rectangulo.w=ttext->w; rectangulo.h=ttext->h; SDL_SetColorKey(ttext,SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(ttext->format,255,0,0)); SDL_BlitSurface(ttext,NULL,screen,&rectangulo); TTF_CloseFont(fuente); SDL_FreeSurface(ttext); while(done == 0){ while(SDL_PollEvent(&event)){ if(event.type == SDL_KEYDOWN) done = 1; } } return 0;}