The static texture loading was replaced by a dynamic loader. Every png file in gfx/ is (recursively) loaded at the beginning and accessed via get_tex(name) or get_ani(name).name for "gfx/stage1/border.png" would be "stage1/border". Sprite information is to be specified in the filename in the pattern: ani_${row count}_${col count}_${animation frequency}_${name}.png
35 lines
No EOL
819 B
C
35 lines
No EOL
819 B
C
/*
|
|
* This software is licensed under the terms of the MIT-License
|
|
* See COPYING for further information.
|
|
* ---
|
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
|
*/
|
|
|
|
#include "font.h"
|
|
#include "global.h"
|
|
#include <assert.h>
|
|
|
|
struct Fonts _fonts;
|
|
|
|
void init_fonts() {
|
|
TTF_Init();
|
|
_fonts.biolinum = TTF_OpenFont(FILE_PREFIX "gfx/LinBiolinum.ttf", 20);
|
|
assert(_fonts.biolinum);
|
|
}
|
|
|
|
Texture *load_text(const char *text, TTF_Font *font) {
|
|
Texture *tex = malloc(sizeof(Texture));
|
|
SDL_Surface *surf = TTF_RenderText_Blended(font, text, ((SDL_Color){255,255,255}));
|
|
assert(surf != NULL);
|
|
|
|
load_sdl_surf(surf, tex);
|
|
SDL_FreeSurface(surf);
|
|
|
|
return tex;
|
|
}
|
|
|
|
void draw_text(const char *text, int x, int y, TTF_Font *font) {
|
|
Texture *tex = load_text(text, font);
|
|
draw_texture_p(x, y, tex);
|
|
free_texture(tex);
|
|
} |