1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
//=============================================================================
#include "CText.h"
void CText::apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip )
{
//Holds offsets
SDL_Rect offset;
//Get offsets
offset.x = x;
offset.y = y;
//Blit
SDL_BlitSurface( source, clip, destination, &offset );
}
CText::CText() {
}
bool CText::DrawText(char *pfont,char *ptext, int psize, SDL_Window *window){
SDL_Color textColor = { 255, 255, 255 };
font = TTF_OpenFont( pfont, psize );
SDL_Surface *message = TTF_RenderText_Solid( font, ptext, textColor );
SDL_Surface *screen;
screen = SDL_GetWindowSurface(window);
CText::apply_surface( 0, 0, message, screen,NULL );
SDL_UpdateWindowSurface(window);
}
//=============================================================================
|