fix(window): the title a program passes to gl_open / gvk_open reaches the window

The runtime opens a game's window before main, titled with the program's name, and
gl_open attached to it without passing its title on (render3d's gvk_open called win_open,
which returns early on Windows and opened a second window on macOS). win_set_title in
cocoa.ll / win32.ll (setTitle: / SetWindowTextW, UTF-8 -> UTF-16; a no-op without a window,
stubbed headless) retitles it from gl_open, and win_open on an open window retitles it on
both platforms.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-17 14:02:23 +03:00
parent bb267ff3d5
commit 1256bbfec7
7 changed files with 93 additions and 3 deletions

View file

@ -20,6 +20,7 @@ import "gl_api.ludic"
# ---- native glue (cocoa.ll / gl.ll) -------------------------------------------
extern function win_gl_attach() -> int = "win_gl_attach"
extern function win_set_title(title: pointer) -> void = "win_set_title"
extern function win_gl_resize(w: int, h: int) = "win_gl_resize"
extern function win_gl_swap() = "win_gl_swap"
extern function win_gl_scale() -> int = "win_gl_scale"
@ -91,6 +92,10 @@ function gl_open(width: int, height: int, title: pointer) -> bool {
if win_gl_attach() == 0 {
win_open(width, height, 1, title) # a plain program: no window yet
if win_gl_attach() == 0 { return false }
} else {
# a game's window was opened before main, titled with the program's name: give it
# the title this call asks for
win_set_title(title)
}
win_gl_resize(width, height)
gl_scale = win_gl_scale()