diff --git a/addons/libLibRetroHost-d.so b/addons/libLibRetroHost-d.so index 75e7f5c..cf226e8 100755 Binary files a/addons/libLibRetroHost-d.so and b/addons/libLibRetroHost-d.so differ diff --git a/build_gdlibretro.sh b/build_gdlibretro.sh index 91a6499..7891b5a 100755 --- a/build_gdlibretro.sh +++ b/build_gdlibretro.sh @@ -2,8 +2,9 @@ git clone https://github.com/gabrielmedici/gdlibretro cd gdlibretro -git submodule update --init --recursive -cmake -DNO_GIT_REVISION=ON -DCMAKE_BUILD_TYPE=Debug -DLINUX=true -DCMAKE_CXX_FLAGS="-DLINUX" . -cmake --build . -cd - -mv -fv "gdlibretro/LibRetroHost/lib/Linux-x86_64/libLibRetroHost-d.so" "addons" +git submodule update --init --recursive && \ +cmake -DNO_GIT_REVISION=ON -DCMAKE_BUILD_TYPE=Debug -DLINUX=true -DCMAKE_CXX_FLAGS="-DLINUX" . && \ +cmake --build . && \ +cd - && \ +mv -fv "gdlibretro/LibRetroHost/lib/Linux-x86_64/libLibRetroHost-d.so" "addons" && \ +rm -rf "gdlibretro/LibRetroHost" diff --git a/main.gd b/main.gd index 5761ffc..21b2def 100644 --- a/main.gd +++ b/main.gd @@ -4,8 +4,15 @@ extends Node func _ready(): var core_path = "res://cores/genesis_plus_gx_libretro.so" # Replace with your actual core path + if not FileAccess.file_exists(core_path): + push_error("Core not found at: " + core_path) + return false + var rom_path = "res://roms/megadrive/Sonic the Hedgehog.bin" # Replace with your actual ROM path - + if not FileAccess.file_exists(rom_path): + push_error("Rom not found at: " + rom_path) + return false + print("Core path: ", core_path) print("ROM path: ", rom_path) diff --git a/project.godot b/project.godot index aaa0c5a..dc1a1c4 100644 --- a/project.godot +++ b/project.godot @@ -37,4 +37,6 @@ renderer/rendering_method.mobile="gl_compatibility" [xr] openxr/enabled=true +openxr/foveation_level=3 +openxr/foveation_dynamic=true shaders/enabled=true diff --git a/scripts/libretro_loader.gd b/scripts/libretro_loader.gd index 82f144e..a906ade 100644 --- a/scripts/libretro_loader.gd +++ b/scripts/libretro_loader.gd @@ -9,8 +9,12 @@ var current_rom : String = "" # Initialize to an empty string func start_emulation(core_path: String, rom_path: String) -> bool: print("Starting emulation with core: ", core_path, ", ROM: ", rom_path) - if not core_path or not rom_path: - push_error("Core path or ROM path is missing.") + if not core_path: + push_error("Core path is missing.") + return false + + if not rom_path: + push_error("ROM path is missing.") return false # Load the core (emulator) @@ -47,19 +51,21 @@ func start_emulation(core_path: String, rom_path: String) -> bool: current_rom = rom_path print("Core and ROM loaded successfully.") - # Wait for SubViewport to render at least one frame + # Ensure SubViewport is ready sub_viewport.render_target_update_mode = SubViewport.UPDATE_ALWAYS - await get_tree().create_timer(0.1).timeout # Delay ensures rendering starts - # Assign the SubViewport texture - var viewport_texture = sub_viewport.get_texture() - if viewport_texture: - texture_rect.texture = viewport_texture - print("SubViewport texture assigned successfully.") - else: - push_error("Error: SubViewport texture is not ready.") + # Wait for the SubViewport to initialize (up to 3 seconds) + var max_wait_time = 3.0 # Maximum wait time in seconds + var elapsed_time = 0.0 + while not sub_viewport.get_texture() and elapsed_time < max_wait_time: + await get_tree().idle_frame # Waits for the next frame + elapsed_time += get_process_delta_time() + if not sub_viewport.get_texture(): + push_error("Error: SubViewport texture is not ready after waiting.") return false + texture_rect.texture = sub_viewport.get_texture() + print("SubViewport texture assigned successfully.") return true func _process(delta):