Something is almost working
This commit is contained in:
11
util/font.c
11
util/font.c
@@ -10,13 +10,13 @@ prepText(SDL_Renderer *renderer, unsigned char pxSize, const char *file, uint8_t
|
||||
BitmapFont out;
|
||||
out.size = pxSize;
|
||||
out.color = (SDL_Color) {r, g, b, a};
|
||||
unsigned char i = 0;
|
||||
unsigned int i = 1;
|
||||
do {
|
||||
char tmpOut[2] = {i, 0};
|
||||
out.surface[i] = TTF_RenderText_Solid(gFont, tmpOut, out.color);
|
||||
out.texture[i] = SDL_CreateTextureFromSurface(renderer, out.surface[i]);
|
||||
i++;
|
||||
} while (i < 255);
|
||||
} while (i < 256);
|
||||
|
||||
TTF_CloseFont(gFont);
|
||||
return out;
|
||||
@@ -43,4 +43,11 @@ void renderText(SDL_Renderer *renderer, BitmapFont font, char *string, uint16_t
|
||||
outRect.x += charRect.w + 1;
|
||||
string++;
|
||||
}
|
||||
}
|
||||
|
||||
void destroyFont(BitmapFont *font) {
|
||||
for (uint16_t i = 1; i < 256; i++) {
|
||||
SDL_DestroyTexture(font->texture[i]);
|
||||
SDL_FreeSurface(font->surface[i]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user