And heres my .cpp file....
#include "SDLCanvas.h"
SDLCanvas::SDLCanvas()
{
pSurface = NULL;
}
SDLCanvas::~SDLCanvas()
{
destroyCanvas();
}
bool SDLCanvas::createCanvas(int width, int height, int bpp, bool windowed)
{
int flags = SDL_SWSURFACE;
pSurface = SDL_SetVideoMode(width, height, bpp, flags);
if(NULL == pSurface)
return false;
return true;
}
void SDLCanvas::destroyCanvas()
{
if(pSurface)
{
SDL_FreeSurface( pSurface );
}
}
bool SDLCanvas::createFont( char* strFontFace, int size )
{
if( TTF_Init() < 0 )
{
//error loading the library...
return false;
}
pFont = TTF_OpenFont(strFontFace, size);
if (pFont == NULL)
{
//error loading font...
return false;
}
return true;
}
void SDLCanvas::printText( char fgR, char fgG, char fgB, char fgA,
char bgR, char bgG, char bgB, char bgA,
char* strText, textquality quality )
{
SDL_Color fgColor = {fgR, fgG, fgB, fgA};
SDL_Color bgColor = {bgR, bgG, bgB, bgA};
if (quality == solid)
{
*pFontSurface = TTF_RenderText_Solid( pFont, strText,
fgColor );
}else if (quality == shaded)
{
*pFontSurface = TTF_RenderText_Shaded( pFont, strText,
fgColor,
bgColor);
}else if (quality == blended)
{
*pFontSurface = TTF_RenderText_Blended( pFont, strText,
fgColor );
}
}