Sun, 21 Jan 2024 13:31:51 +0100
rename AscTextNode to just AscText
src/ascension/text.h | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions | |
test/sandbox.c | file | annotate | diff | comparison | revisions |
--- a/src/ascension/text.h Thu Jan 18 21:58:58 2024 +0100 +++ b/src/ascension/text.h Sun Jan 21 13:31:51 2024 +0100 @@ -32,7 +32,7 @@ #include "datatypes.h" #include <cx/buffer.h> -typedef struct AscTextNode { +typedef struct AscText { char *text; AscFont const *font; asc_vec2i position; @@ -44,7 +44,7 @@ asc_vec2i dimension; unsigned tex_id; } internal; -} AscTextNode; +} AscText; /** @@ -61,7 +61,7 @@ * @see asc_ink() * @see asc_font() */ -AscTextNode *asc_text(int x, int y, char const* text); +AscText *asc_text(int x, int y, char const* text); /** * Updates the internal state of the text node. @@ -71,20 +71,20 @@ * * @param node the text node */ -void asc_text_update(AscTextNode *node); +void asc_text_update(AscText *node); /** * Draws the text node in the current frame. * * @param node the text node */ -void asc_text_draw(AscTextNode *node); +void asc_text_draw(AscText *node); /** * Releases all the memory of this node. * * @param node the text node */ -void asc_text_free(AscTextNode *node); +void asc_text_free(AscText *node); #endif //ASCENSION_TEXT_H
--- a/src/text.c Thu Jan 18 21:58:58 2024 +0100 +++ b/src/text.c Sun Jan 21 13:31:51 2024 +0100 @@ -32,8 +32,8 @@ #include <GL/glew.h> -AscTextNode *asc_text(int x, int y, char const *text) { - AscTextNode *node = calloc(1, sizeof(AscTextNode)); +AscText *asc_text(int x, int y, char const *text) { + AscText *node = calloc(1, sizeof(AscText)); if (node == NULL) { asc_error("Out of memory."); return NULL; @@ -49,7 +49,7 @@ return node; } -void asc_text_update(AscTextNode *node) { +void asc_text_update(AscText *node) { // short circuit if fully transparent or hidden, we don't need anything if (node->color.alpha == 0 || node->hidden) { return; @@ -93,7 +93,7 @@ SDL_FreeSurface(surface); } -void asc_text_draw(AscTextNode *node) { +void asc_text_draw(AscText *node) { if (node->color.alpha == 0 || node->hidden) { return; } @@ -128,7 +128,7 @@ asc_primitives_draw_plane(); } -void asc_text_free(AscTextNode *node) { +void asc_text_free(AscText *node) { asc_dprintf("Release text node texture: %u", node->internal.tex_id); glDeleteTextures(1, &node->internal.tex_id); free(node->text);
--- a/test/sandbox.c Thu Jan 18 21:58:58 2024 +0100 +++ b/test/sandbox.c Sun Jan 21 13:31:51 2024 +0100 @@ -54,7 +54,7 @@ asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); asc_ink_rgb(255, 0, 0); - AscTextNode *fps_counter = asc_text(50, 50, "9999 FPS"); + AscText *fps_counter = asc_text(50, 50, "9999 FPS"); unsigned last_fps = 0; while (asc_loop_next()) {