aboutsummaryrefslogtreecommitdiff
path: root/src/cdraw.c
diff options
context:
space:
mode:
authorKrow Savcik <krow@savcik.xyz>2024-02-13 18:31:38 +0200
committerKrow Savcik <krow@savcik.xyz>2024-02-13 18:31:38 +0200
commit306691b02acce8711ad82c8efc736164e1fe7cd2 (patch)
treebbe81b65cf1b07e6a5c0ca1d870a33612c87f66a /src/cdraw.c
parent669f50e2d6fc55751e0f3afb4d1bdf633446b169 (diff)
feature: simple text rendering ability
Diffstat (limited to 'src/cdraw.c')
-rw-r--r--src/cdraw.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/cdraw.c b/src/cdraw.c
index ecec5de..6088df9 100644
--- a/src/cdraw.c
+++ b/src/cdraw.c
@@ -1,12 +1,18 @@
#include <stdio.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
+#define SBDF_IMPLEMENTATION
+#define SBDF_USESDL
+#include "sbdf.h"
#include "cdraw.h"
#include "types.h"
+#include "debug.h"
#include "action.h"
#include "canvas.h"
-#include "debug.h"
#include "palette.h"
#include "ui.h"
@@ -21,6 +27,7 @@ typedef struct {
SDL_Window *win;
void *ren;
+void *font;
void *def_palette;
struct Canvas* cur_canvas;
@@ -50,12 +57,15 @@ main_quit()
SDL_DestroyWindow(win);
IMG_Quit();
SDL_Quit();
+ SBDF_FontDestroy(font);
+ font = NULL;
return 1;
}
uint
main_window_init(const char *s)
{
+ /* TODO: defer*/
int ss;
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("SDL_Init failed: %s\n", SDL_GetError());
@@ -88,6 +98,10 @@ main_window_init(const char *s)
if (def_palette == NULL)
return 1;
+ font = SBDF_FontLoad(def_font);
+ if (font == NULL)
+ return 1;
+
ui_create(def_theme_path);
if (s == NULL)
cur_canvas = canvas_init(64, 64, ren);