changes to build system, emscipten progress (can render solid color, yippie!)

This commit is contained in:
veclavtalica
2025-02-21 19:06:19 +03:00
parent dd4fc45be3
commit f25e27b102
11 changed files with 29 additions and 12 deletions

View File

@ -24,9 +24,9 @@
static void pack_contents_modified(char const *path, enum FilewatchAction action);
#ifndef EMSCRIPTEN
static SDL_sem *opengl_load_semaphore;
#endif
/* note: it drives most of IO implicitly, such as audio callbacks */
static void poll_events(void) {
@ -425,6 +425,7 @@ static bool initialize(void) {
toml_datum_t datum_debug = toml_bool_in(game, "debug");
ctx.game.debug = datum_debug.ok ? datum_debug.u.b : true;
#ifndef EMSCRIPTEN
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
@ -441,6 +442,11 @@ static bool initialize(void) {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
#else
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
#endif
toml_datum_t datum_title = toml_string_in(about, "title");
if (!datum_title.ok)
datum_title.u.s = SDL_strdup("townengine project");
@ -624,9 +630,11 @@ static bool initialize(void) {
profile_end("game object load");
/* delayed as further as possible so that more work is done before we have to wait */
#ifndef EMSCRIPTEN
SDL_SemWait(opengl_load_semaphore);
SDL_DestroySemaphore(opengl_load_semaphore);
profile_end("opengl loading");
#endif
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1");
@ -763,6 +771,7 @@ int enter_loop(int argc, char **argv) {
}
profile_end("SDL initialization");
#ifndef EMSCRIPTEN
profile_start("opengl loading");
opengl_load_semaphore = SDL_CreateSemaphore(0);
SDL_Thread *opengl_load_thread = SDL_CreateThread(opengl_load_thread_fn, "opengl loader", opengl_load_semaphore);
@ -773,6 +782,7 @@ int enter_loop(int argc, char **argv) {
SDL_DetachThread(opengl_load_thread);
opengl_load_thread = NULL;
#endif
ctx.argc = argc;
ctx.argv = argv;