summaryrefslogtreecommitdiff
path: root/src/sdl_fb.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-13 21:36:00 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-13 21:47:56 -0700
commit1446525ac78b25932db12e4e690184b137fc6aa8 (patch)
tree46434c9363d4acf7610abaa7f863f660ecaa35b4 /src/sdl_fb.c
parent2f4011b4c5ec416d78d6da304315708a42e39798 (diff)
til_args,*_fb: introduce --title= and wire up to til_fb_t
For meta-demo use cases like alphazed is experimenting with, it's desirable to change the window title from "rototiller" to "alphazed" or whatever if in windowed mode. This adds a way to do that in the obvious fashion... --title="alphazed" etc.
Diffstat (limited to 'src/sdl_fb.c')
-rw-r--r--src/sdl_fb.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sdl_fb.c b/src/sdl_fb.c
index 6a67411..6221a83 100644
--- a/src/sdl_fb.c
+++ b/src/sdl_fb.c
@@ -24,6 +24,7 @@ struct sdl_fb_page_t {
};
typedef struct sdl_fb_t {
+ const char *title;
unsigned width, height;
Uint32 flags;
@@ -137,12 +138,13 @@ static int sdl_err_to_errno(int err)
}
}
-static int sdl_fb_init(const til_setup_t *setup, void **res_context)
+static int sdl_fb_init(const char *title, const til_setup_t *setup, void **res_context)
{
sdl_fb_setup_t *s = (sdl_fb_setup_t *)setup;
sdl_fb_t *c;
int r;
+ assert(title);
assert(setup);
assert(res_context);
@@ -157,6 +159,12 @@ static int sdl_fb_init(const til_setup_t *setup, void **res_context)
c->flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
}
+ c->title = strdup(title);
+ if (!c->title) {
+ free(c);
+ return -ENOMEM;
+ }
+
c->width = s->width;
c->height = s->height;
@@ -208,7 +216,7 @@ static int sdl_fb_acquire(til_fb_t *fb, void *context, void *page)
{
sdl_fb_t *c = context;
- c->window = SDL_CreateWindow("rototiller", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, c->width, c->height, c->flags);
+ c->window = SDL_CreateWindow(c->title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, c->width, c->height, c->flags);
if (!c->window)
return -1;
© All Rights Reserved