Text::Text(Ttf* font, const char* text, unsigned char r, unsigned char g, unsigned char b)
{
SDL_Surface* s = NULL;
SDL_Surface* socle = NULL;
SDL_Color color = {r, g, b, 0};
unsigned short w = 1, h = 1;
s = TTF_RenderText_Blended(font->GetFont(), text, color);
while (s->w > w)
w = w << 1;
while (s->h > h)
h = h << 1;
w < h ? w = h : h = w;
if(s > 0)
{
socle = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, s->format->Rmask, s->format->Gmask, s->format->Bmask, s->format->Amask);
SDL_BlitSurface(s, NULL, socle, NULL);
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, socle->w, socle->h, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, socle->pixels);
}
SDL_FreeSurface(s);
SDL_FreeSurface(socle);
}