From bdc6e6af796440f06b37f204aedc40d9220f975d Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sun, 23 Feb 2025 22:22:02 -0500 Subject: set window title --- main.c | 3 ++- renderer.c | 14 ++++++++++++-- renderer.h | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 847209a..4660c49 100644 --- a/main.c +++ b/main.c @@ -51,7 +51,7 @@ main(void) { /* Init microui. */ static mu_Context ctx; mu_init(&ctx); - r_init(&ctx); + r_init(&ctx, TITLE); set_style(&ctx); /* Init data structures. */ @@ -115,5 +115,6 @@ main_window(mu_Context *ctx, UI *ui) { static char buf[64]; snprintf(buf, sizeof(buf), "%lf", value); mu_label(ctx, buf); + mu_label(ctx, "abcdefghijklmnopqrstuvwxyz0123456789"); mu_end_window(ctx); } diff --git a/renderer.c b/renderer.c index 7de6793..2fd0a37 100644 --- a/renderer.c +++ b/renderer.c @@ -12,6 +12,7 @@ enum window { WIDTH = 640, HEIGHT = 480, WINFLAGS = SDL_WINDOW_RESIZABLE, + RENDERFLAGS = 0, }; static const char FONT[] = "font/charter-regular.ttf"; @@ -52,12 +53,21 @@ static SDL_Renderer *renderer = NULL; /* Initialize the window and renderer. Returns non-zero on error. */ int -r_init(mu_Context *ctx) { +r_init(mu_Context *ctx, const char *title) { if (SDL_Init(SDL_INIT_VIDEO) != 0) { fprintf(stderr, "%s\n", SDL_GetError()); return 1; } - if (SDL_CreateWindowAndRenderer(WIDTH, HEIGHT, WINFLAGS, &window, &renderer) != 0) { + window = SDL_CreateWindow(title, + SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, + WIDTH, HEIGHT, + WINFLAGS); + if (!window) { + fprintf(stderr, "%s\n", SDL_GetError()); + return 1; + } + renderer = SDL_CreateRenderer(window, -1, RENDERFLAGS); + if (!renderer) { fprintf(stderr, "%s\n", SDL_GetError()); return 1; } diff --git a/renderer.h b/renderer.h index c5187fe..72d59dc 100644 --- a/renderer.h +++ b/renderer.h @@ -1,4 +1,4 @@ -int r_init(mu_Context *ctx); +int r_init(mu_Context *ctx, const char *title); void r_input(mu_Context *ctx); void r_render(mu_Context *ctx); void r_get_window_size(int *w, int *h); \ No newline at end of file -- cgit v1.2.3