aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-02-23 22:22:02 -0500
committerSam Anthony <sam@samanthony.xyz>2025-02-23 22:22:02 -0500
commitbdc6e6af796440f06b37f204aedc40d9220f975d (patch)
tree48ea650a343fd97b8c4ff14f0d6294a89eed9c18
parentedfe8f1452115a94b2371daf7c150f7a6ac2a2f0 (diff)
downloadvolute-bdc6e6af796440f06b37f204aedc40d9220f975d.zip
set window title
-rw-r--r--main.c3
-rw-r--r--renderer.c14
-rw-r--r--renderer.h2
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