Checkpoint

This commit is contained in:
XargonWan 2024-12-18 15:48:50 +09:00
parent de0e5f357d
commit f20ff575b0
5 changed files with 33 additions and 17 deletions

Binary file not shown.

View file

@ -2,8 +2,9 @@
git clone https://github.com/gabrielmedici/gdlibretro git clone https://github.com/gabrielmedici/gdlibretro
cd gdlibretro cd gdlibretro
git submodule update --init --recursive git submodule update --init --recursive && \
cmake -DNO_GIT_REVISION=ON -DCMAKE_BUILD_TYPE=Debug -DLINUX=true -DCMAKE_CXX_FLAGS="-DLINUX" . cmake -DNO_GIT_REVISION=ON -DCMAKE_BUILD_TYPE=Debug -DLINUX=true -DCMAKE_CXX_FLAGS="-DLINUX" . && \
cmake --build . cmake --build . && \
cd - cd - && \
mv -fv "gdlibretro/LibRetroHost/lib/Linux-x86_64/libLibRetroHost-d.so" "addons" mv -fv "gdlibretro/LibRetroHost/lib/Linux-x86_64/libLibRetroHost-d.so" "addons" && \
rm -rf "gdlibretro/LibRetroHost"

View file

@ -4,8 +4,15 @@ extends Node
func _ready(): func _ready():
var core_path = "res://cores/genesis_plus_gx_libretro.so" # Replace with your actual core path 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 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("Core path: ", core_path)
print("ROM path: ", rom_path) print("ROM path: ", rom_path)

View file

@ -37,4 +37,6 @@ renderer/rendering_method.mobile="gl_compatibility"
[xr] [xr]
openxr/enabled=true openxr/enabled=true
openxr/foveation_level=3
openxr/foveation_dynamic=true
shaders/enabled=true shaders/enabled=true

View file

@ -9,8 +9,12 @@ var current_rom : String = "" # Initialize to an empty string
func start_emulation(core_path: String, rom_path: String) -> bool: func start_emulation(core_path: String, rom_path: String) -> bool:
print("Starting emulation with core: ", core_path, ", ROM: ", rom_path) print("Starting emulation with core: ", core_path, ", ROM: ", rom_path)
if not core_path or not rom_path: if not core_path:
push_error("Core path or ROM path is missing.") push_error("Core path is missing.")
return false
if not rom_path:
push_error("ROM path is missing.")
return false return false
# Load the core (emulator) # Load the core (emulator)
@ -47,19 +51,21 @@ func start_emulation(core_path: String, rom_path: String) -> bool:
current_rom = rom_path current_rom = rom_path
print("Core and ROM loaded successfully.") 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 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 # Wait for the SubViewport to initialize (up to 3 seconds)
var viewport_texture = sub_viewport.get_texture() var max_wait_time = 3.0 # Maximum wait time in seconds
if viewport_texture: var elapsed_time = 0.0
texture_rect.texture = viewport_texture while not sub_viewport.get_texture() and elapsed_time < max_wait_time:
print("SubViewport texture assigned successfully.") await get_tree().idle_frame # Waits for the next frame
else: elapsed_time += get_process_delta_time()
push_error("Error: SubViewport texture is not ready.") if not sub_viewport.get_texture():
push_error("Error: SubViewport texture is not ready after waiting.")
return false return false
texture_rect.texture = sub_viewport.get_texture()
print("SubViewport texture assigned successfully.")
return true return true
func _process(delta): func _process(delta):