0

Here's an example:

SDL_Color textcol = {255, 255, 255};
SDL_Color backtextcol = {0, 0, 0};
SDL_Surface *mes = TTF_RenderText_Shaded(font, "The game has begun", textcol, backtextcol);
apply_surface(40, 40, mes, screen);
SDL_Flip(screen);

Thanks to that example, we draw a black rectangle with white letters. Is it possible to draw just white letters with black inside without the whole black rectangle?

Allok
  • 737
  • 1
  • 7
  • 19

1 Answers1

1

Yes it is possible. There are 3 main text-drawing functions in SDL_TTF:

TTF_RenderText_Solid - this one renders basic text(whitout background) and its fast, but its low-quality, and will look pixellated.

TTF_RenderText_Shaded - this one draws nice blended characters, but to a pre-defined background color

TTF_RenderText_Blended - this one draws a nice blended text, but it uses alpha-blending and its slow, but gives very nice results

akaltar
  • 1,002
  • 1
  • 19
  • 25
  • I use _Shaded in my example, but it draws a big black rectangle with the white message. But I want just message without rectangle. If I use _Solid, it draws white letters with transparent inside – Allok May 30 '12 at 18:07
  • Sorry but I dont understand what you want to achieve. Could you post some image or something to make things clear? what you exactly want? Perhaps the letters are transparent because you use a font that should be like that? – akaltar May 30 '12 at 20:24