Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mikesmullin opened this issue Oct 20, 2024 · 3 comments · Fixed by #1186
Closed

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

mikesmullin opened this issue Oct 20, 2024 · 3 comments · Fixed by #1186
Assignees

Comments

@mikesmullin
Copy link

mikesmullin commented Oct 20, 2024

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
Copy link
Owner

floooh commented Oct 23, 2024

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.

@floooh floooh self-assigned this Oct 23, 2024
@mikesmullin
Copy link
Author

Because I see you working on WebGPU support, I linked Sokol next to my SDL reference in the WebAssembly/WASI Issue 53. 😄

I am imagining a day when we'll compile for WASM-first, and via a WASI Interface we have cross-platform (portable) control of Window, WebGPU, etc. We'll compile and debug .c as .wasm primarily/exclusively. From there we'll compile .wasm to native machine code for all platforms, or a Universal binary (like Cosmopolitan). 🤞

Until then, there is Sokol.

floooh added a commit that referenced this issue Jan 12, 2025
When this is true, sokol_app.h will set the HTML document.title
to sapp_desc.window_title.

Fixes #1132
@floooh floooh closed this as completed in 6fe7556 Jan 12, 2025
@floooh
Copy link
Owner

floooh commented Jan 12, 2025

Ok, I'm using this on the Tiny Emulators now, for instance Amstrad CPC: https://floooh.github.io/tiny8bit/cpc.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants