options gen2
require daslib/fio

[export]
def initialize(project_path : string) {
    // the boost layer; the raw gl* module (opengl.das) stays registration-free here on
    // purpose - on web the native C++ module provides Module("opengl"), and a registered
    // path would resolve the pure-das late-extern layer over it
    register_native_path("opengl", "opengl_boost_internal", "{project_path}/opengl/opengl_boost_internal.das")
    register_native_path("opengl", "opengl_boost", "{project_path}/opengl/opengl_boost.das")
    register_native_path("opengl", "opengl_state", "{project_path}/opengl/opengl_state.das")
    register_native_path("opengl", "opengl_ttf", "{project_path}/opengl/opengl_ttf.das")
    register_native_path("opengl", "opengl_gen", "{project_path}/opengl/opengl_gen.das")
    register_native_path("opengl", "opengl_cache", "{project_path}/opengl/opengl_cache.das")
    register_native_path("opengl", "opengl_imgui_driver", "{project_path}/opengl/opengl_imgui_driver.das")
    register_native_path("live", "opengl_live", "{project_path}/opengl/opengl_live.das")
    register_native_path("glsl", "glsl_opengl", "{project_path}/glsl/glsl_opengl.das")
    // Register the native C++ opengl module ONLY when this host is cross-compiling for
    // the web. The desktop host then has Module("opengl")'s signatures to emit handled-
    // extern dispatch for the wasm target (ensure_module registers it there; emcc links
    // the real GLES3 glue). On desktop the module is signatures-only stubs that link but
    // never run (see dasOpenGL.desktop_stubs.cpp). Normal desktop runs keep opengl.das.
    // The emscripten interpreter build registers it via CMake ADD_MODULE_CPP instead
    // (das_is_dll_build() is false in the static wasm monolith).
    if (das_is_dll_build() && get_cross_platform_name() == "emscripten") {
        register_dynamic_module("{project_path}/dasModuleOpenGL.shared_module", "Module_dasOpenGL")
    }
}
