diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-02-23 22:22:02 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-02-23 22:22:02 -0500 |
| commit | bdc6e6af796440f06b37f204aedc40d9220f975d (patch) | |
| tree | 48ea650a343fd97b8c4ff14f0d6294a89eed9c18 | |
| parent | edfe8f1452115a94b2371daf7c150f7a6ac2a2f0 (diff) | |
| download | volute-bdc6e6af796440f06b37f204aedc40d9220f975d.zip | |
set window title
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | renderer.c | 14 | ||||
| -rw-r--r-- | renderer.h | 2 |
3 files changed, 15 insertions, 4 deletions
@@ -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); } @@ -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; } @@ -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 |