floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.05k stars 494 forks source link

sokol `sapp_desc.window_title` should apply to Emscripten `window.title` too #1132

Open mikesmullin opened 2 weeks ago

mikesmullin commented 2 weeks ago

Just wanted to share my workaround solution.

sapp_desc sokol_main(int argc, char* argv[]) {
  (void)argc;
  (void)argv;

  char* window_title = "Retro";

#ifdef __EMSCRIPTEN__
  EM_ASM({ document.title = UTF8ToString($0); }, window_title);
#endif

  return (sapp_desc){
      .init_cb = init,
      .frame_cb = frame,
      .cleanup_cb = cleanup,
      .width = 640,
      .height = 640,
      .html5_canvas_resize = true,
      .window_title = window_title,
      .icon.sokol_default = false,
      .logger.func = slog_func,
      .win32_console_utf8 = true,
      .win32_console_attach = true,
  };
}

full application here

floooh commented 2 weeks ago

Weird, I thought I had written a reply but apparently not :)

It's a nice and simple fix that could also go directly into sokol_app.h (I can't think of a specific reason why I don't update the window title like that tbh).

I'll keep the ticket open as reminder for myself to add a similar fix to sokol_app.h.