Here are some functions I made for SDL abstraction:

SDL_Surface* getImage(string filename, int r=255, int g=0, int b=198) 
    SDL_Surface* loadedImage=0;
    SDL_Surface* optimizedImage=0;
    optimizedImage = SDL_DisplayFormat(loadedImage);
    Uint32 colorkey=SDL_MapRGB(optimizedImage->format, r, g, b);
    SDL_SetColorKey(optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey);

    return optimizedImage;

void drawSurface(int x, int y, SDL_Surface* source, SDL_Surface* destination, int cX=0, int cY=0, int cW=0, int cH=0)
    SDL_Rect offset={x, y};
    SDL_Rect clip={cX, cY, cW, cH};
    SDL_Rect* pClip=&clip;
    if(!cX && !cY && !cW && !cH)
	SDL_BlitSurface(source, 0, destination, &offset);
	SDL_BlitSurface(source, pClip, destination, &offset);

void drawText(int x, int y, string text, SDL_Surface* destination, TTF_Font* font,  int fR=255, int fG=255, int fB=255, int bR=0, int bG=0, int bB=0)
     SDL_Color foregroundColor={fR, fG, fB};
     SDL_Color backgroundColor={bR, bG, bB};

     SDL_Surface* textSurface=TTF_RenderText_Shaded(font, text.c_str(), foregroundColor, backgroundColor);

     apply_surface(x, y,  textSurface, destination);

About the Author

I'm a Nethack and MUD addict.

um sorry.. but line 35 should be drawSurface.