Hey guys please can someone help me out with this! I've being pulling my hair out for about 4 hours with it!
So I'm following the tutorials over at
lazyfoo about loading a font system in, I've had to slice it up a bit to go along with what is already in my code but I'm having a few problems, namely that it doesn't actually work [bawling] I don't get any compiler errors however it doesn't display the text.
Here is the code that I am using at the moment:
// class constructor
text::text()
{
// Initialise TTF
TTF_Init() == -1;
}
bool text::loadFont (SDL_Surface *screen)
{
// Load TTF font
TTF_Font *font;
if (font == NULL)
{ return false; }
// create the surface for a message
SDL_Surface *messageText;
// set the font color to black (tried with white too but no joy)
SDL_Color textColor = {0, 0, 0, 0};
// load the font
font = TTF_OpenFont ( "lazy.ttf", 16);
// assign the text to the surface
messageText = TTF_RenderText_Solid( font, "why does this not render?", textColor);
// use drawGFX to render the text
drawGFX (10, 10, messageText, screenSurface);
return true;
}
drawGFX is in a seperate visualisation class and it looks like this:
void visualisation::drawGFX( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;
//Give the offsets to the rectangle
offset.x = x;
offset.y = y;
//Blit the surface
SDL_BlitSurface( source, NULL, destination, &offset );
}
this works for blitting bitmaps and PNG files without a problem, doesn't anyone have any ideas as to what could possibly be wrong with it?
Cheers for your help
-pete-