-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext.c
More file actions
55 lines (48 loc) · 1.14 KB
/
Copy pathtext.c
File metadata and controls
55 lines (48 loc) · 1.14 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <SDL.h>
#include <SDL_ttf.h>
#include "graphics.h"
#include "imagen.h"
#include "text.h"
#include <stdio.h>
TTF_Font *font = 0;
void textuaGaitu(void)
{
font = TTF_OpenFontIndex("OpenSans-Regular.ttf", 16, 0);
if (!font)
{
printf("TTF_OpenFontIndex: %s\n", TTF_GetError());
// handle error
}
}
void textuaIdatzi(int x, int y, char *str)
{
SDL_Surface *textSurface;
SDL_Texture *mTexture;
SDL_Color textColor = {0XFF, 0XFF, 0XFF};
SDL_Rect src, dst;
SDL_Renderer *gRenderer;
if (font == 0)
{
return;
}
gRenderer = getRenderer();
textSurface = TTF_RenderText_Solid(font, str, textColor);
mTexture = SDL_CreateTextureFromSurface(gRenderer, textSurface);
src.x = 0;
dst.x = x;
src.y = 0;
dst.y = y;
src.w = dst.w = textSurface->w;
src.h = dst.h = textSurface->h;
SDL_RenderCopy(gRenderer, mTexture, &src, &dst);
SDL_FreeSurface(textSurface);
SDL_DestroyTexture(mTexture);
}
void textuaDesgaitu(void)
{
if (font != 0)
{
TTF_CloseFont(font);
}
font = 0;
}