comparison src/core/debug.c @ 94:ed72843a7194

core: simplify font/texture interfaces Expose the structure to avoid calling functions and heap allocations. While here remove some useless functions.
author David Demelier <markand@malikania.fr>
date Mon, 30 Mar 2020 13:34:42 +0200
parents 8f95462ac5f8
children
comparison
equal deleted inserted replaced
93:d4a72fa16225 94:ed72843a7194
49 { 49 {
50 assert(report); 50 assert(report);
51 assert(fmt); 51 assert(fmt);
52 52
53 char line[DEBUG_LINE_MAX]; 53 char line[DEBUG_LINE_MAX];
54 struct texture *tex; 54 struct texture tex;
55 struct font *font; 55 struct font *font;
56 unsigned int gapy; 56 unsigned int gapy;
57 57
58 vsnprintf(line, sizeof (line), fmt, ap); 58 vsnprintf(line, sizeof (line), fmt, ap);
59
59 font = report->font ? report->font : debug_options.default_font; 60 font = report->font ? report->font : debug_options.default_font;
60 tex = font_render_ex(font, line, report->color, report->style); 61 font->color = report->color;
62 font->style = report->style;
61 63
62 if (!tex) 64 if (!font_render(font, &tex, line))
63 return; 65 return;
64 66
65 gapy = (PADDING_Y * (report->count)) + 67 gapy = (PADDING_Y * (report->count)) +
66 (font_height(font) * (report->count)); 68 (font_height(font) * (report->count));
67 report->count++; 69 report->count++;
68 70
69 texture_draw(tex, PADDING_X, gapy); 71 texture_draw(&tex, PADDING_X, gapy);
70 texture_close(tex); 72 texture_finish(&tex);
71 } 73 }