0
|
1 #include "dmlib.h"
|
|
2
|
|
3 void dmDrawTTFTextConst(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt)
|
|
4 {
|
|
5 SDL_Surface *text = TTF_RenderText_Blended(font, fmt, col);
|
|
6 if (text)
|
|
7 {
|
|
8 SDL_Rect rect;
|
|
9 rect.x = x;
|
|
10 rect.y = y;
|
|
11 rect.w = text->w;
|
|
12 rect.h = text->h;
|
|
13 SDL_BlitSurface(text, NULL, screen, &rect);
|
|
14 SDL_FreeSurface(text);
|
|
15 }
|
|
16 }
|
|
17
|
|
18 void dmDrawTTFTextVA(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, va_list ap)
|
|
19 {
|
|
20 char *tmp = dm_strdup_vprintf(fmt, ap);
|
|
21 if (tmp != NULL)
|
|
22 {
|
|
23 dmDrawTTFTextConst(screen, font, col, x, y, tmp);
|
|
24 dmFree(tmp);
|
|
25 }
|
|
26 }
|
|
27
|
|
28 void dmDrawTTFText(SDL_Surface *screen, TTF_Font *font, SDL_Color col, int x, int y, const char *fmt, ...)
|
|
29 {
|
|
30 va_list ap;
|
|
31
|
|
32 va_start(ap, fmt);
|
|
33 dmDrawTTFTextVA(screen, font, col, x, y, fmt, ap);
|
|
34 va_end(ap);
|
|
35 }
|
|
36
|