Rodrigodd / gameroy

A Game Boy emulator, disassembler and debugger, written in Rust
Apache License 2.0
266 stars 6 forks source link

Release and source do not work on Wayland #7

Closed zenzoa closed 1 year ago

zenzoa commented 1 year ago

I'm running Arch Linux with the wayland compositor/wm Hyprland. I tried running the latest release but Gameroy panicked upon receiving an invalid window handle: image

I then cloned the latest source and got it to compile and run, but I only see a blank screen with a green bar on the bottom. Pressing F12 does not bring up the debug window: image

(Also, small thing, but your readme has a typo: you have to run cargo run --release -p gameroy-native not gameroy_native)

Rodrigodd commented 1 year ago

I tried running the latest release but Gameroy panicked upon receiving an invalid window handle

To be honest, I never tested it on a real Linux environment, only under Windows subsystem for linux. And only tested using VcXsrv Windows X Server, not wayland.

But looking at where the error happened, it appears that the window became invalid in the middle of the texture loading? Not sure if the source line is right, actually. A backtrace should be more accurate.

I only see a blank screen with a green bar on the bottom. Pressing F12 does not bring up the debug window

Try passing a gameboy ROM as argument: cargo run --release -p gameroy-native -- path/to/rom. It should open the game directly, where you can press F12.

With no argument, it should open the ROM list screen. It should appear similar to the window that you are getting, but with some buttons at the top for loading a ROM. You can configure a path to folder containing ROMs in gameroy.toml, to show them in the list.

Actually, the buttons will not appear if you disable the rfd feature, maybe you have done that when trying to build?

You can enable logging by setting the RUST_LOG=info env var, to see if anything else is going wrong.

you have to run cargo run --release -p gameroy-native not gameroy_native

At some point I renamed the package name, and forget to fix the README. Thanks for point out!

zenzoa commented 1 year ago

I tried loading a ROM directly, as well as creating a roms folder - turns out it does work just fine, only Wayland (or at least Hyprland) is getting the wrong window sizing/positioning info:

image

image

image

Rodrigodd commented 1 year ago

But looking at where the error happened, it appears that the window became invalid in the middle of the texture loading? Not sure if the source line is right, actually.

Looking back at this, it is obvious that the source line is wrong, because it is an older version. Also, in this older version I was still using a poorly maintained OpenGL backend, where the error is probably coming from.

turns out it does work just fine, only Wayland (or at least Hyprland) is getting the wrong window sizing/positioning info:

Hmm, it is strangely cropping to the bottom-left corner? I would expect to be cropping in the top-left corner at least.

This error can be originating at 5 points: In the GUI rendering, in my OpenGL sprite renderer, in the opengl bindings, in Winit Wayland backend, or in Hyprlan. Probably isn't in the GUI rendering, bottom-left corner appear to be too strange behavior. Also, I have seen some screenshots of alacritty (which uses winit) running on Hyprland, so probably isn't winit or Hyprland.

If you could, try running the example as describe in the README of Rodrigodd/sprite-render-rs. If this is matching with the screenshot in the README, try running the example in Rodrigodd/giui.

If sprite-render-rs is not working, try running the window example in this tag of Glutin: rust-windowing/glutin/v0.30.3. The example should display a centered triangle. If this is not working, try again the example but in the last commit this time. If neither are working, the problem is upstream.

Also, are you applying scaling in your Hyprland config? Try setting it to 1, could be a problem with DPI awareness somewhere.

zenzoa commented 1 year ago

I skipped ahead to the scaling on Hyprland, since I had it set to 1.5. Changed it to 1, and it works:

image

image

image

It does get distorted when I resize the window:

image

Rodrigodd commented 1 year ago

I was able to test the program in a Wayland compositor (weston in this case), and was able to reproduce the problem with the resizing (but I didn't find out how to increase the scale factor).

The problem was that I forget to call resize on the OpenGL surface, which is necessary on Wayland and macOS. For reference, the fix is here: https://github.com/Rodrigodd/sprite-render-rs/commit/7d7032de91cb4ed0d877d43084cf01ddb98350e4.

I also update the version of sprite-render in master.

Could you test the last commit? It will probably fix the resizing problem, but I don't know if it will also fix the scaling.

Rodrigodd commented 1 year ago

I tested this on both weston and sway, on a actual linux machine, and everything appears to be working.

@zenzoa fell free to reopen if the problem persists on hyprland.