Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Support #3

Open
1 of 2 tasks
zkxs opened this issue Aug 7, 2023 · 7 comments
Open
1 of 2 tasks

MacOS Support #3

zkxs opened this issue Aug 7, 2023 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@zkxs
Copy link
Owner

zkxs commented Aug 7, 2023

Simple Crosshair Overlay should mostly work on MacOS, but I don't have access to a system to test that on and I'm very doubtful it will work out of the box without any platform specific tweaks.

Homework for me:

  • publish MacOS binaries

Homework for you, dear reader:

  • Test on MacOS

If anyone gives this a try I recommend starting the program from a terminal, so when it inevitably crashes you can capture the backtrace for us to analyze.

@zkxs zkxs added the help wanted Extra attention is needed label Aug 7, 2023
@zkxs zkxs changed the title Test on MacOS / Linux Test on MacOS Aug 7, 2023
@zkxs zkxs changed the title Test on MacOS MacOS Support Aug 23, 2023
@zkxs zkxs added the enhancement New feature or request label Nov 16, 2023
@TartanBeardy
Copy link

Hi I have followed the instructions, installed Rust, and it downloaded and installed. Now what do I do? How do I run it?

@zkxs
Copy link
Owner Author

zkxs commented Jan 15, 2024

Hi, thanks for being the first person to try it on Mac. I'm not sure which set of instructions you followed. If it was the "Installing from Source" section, you should be able to just run simple-crosshair-overlay as a command in your terminal.

@akilegaspi
Copy link
Contributor

akilegaspi commented Apr 5, 2024

Hi, thanks for the work @zkxs:

Here's the exception I get when running the binary and also building from source.

thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.10/src/platform_impl/macos/event_loop.rs:200:13:
`winit` requires control over the principal class. You must create the event loop before other parts of your application initialize NSApplication
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@akilegaspi
Copy link
Contributor

Submitted a PR regarding the exception I mentioned here #52

@zkxs
Copy link
Owner Author

zkxs commented Apr 5, 2024

#52 is merged and included in release 1.1.3. Please let me know if it works on Mac with this change: I'd like to make note of any known issues (or lack thereof) in the readme.

@akilegaspi
Copy link
Contributor

Works on Mac except the crosshair is not on a transparent layer but black layer, I haven't figured out yet how to fix it

@zkxs
Copy link
Owner Author

zkxs commented Apr 6, 2024

Hmm, I've only got a couple of ideas:

  1. On Windows, I found that the window behavior is very sensitive to the order in which I set window settings, especially that some can only be changed after the window is already visible. You can see in init_window the aftermath of me fighting with Windows for a while to get things working as desired. I wouldn't be surprised if MacOS has similar things going on. Don't be afraid to totally reorder everything I'm doing in that function and see if it changes anything. In particular, try removing the .with_visible(false) call and see if anything happens.
  2. Windows expects ARGB with premultiplied alpha. I don't know if Mac expects this pixel format, so I currently am using my best-guess and giving it ARGB with normal alpha (no premultiplication). If this is affecting you then with the default red + crosshair the background would be transparent as expected, but the red crosshair would be fully opaque instead of the intended 70% opaque. If you suspect that it might need premultiplied alpha, try out this change I've put on a new macos-premultiply-alpha branch. If MacOS wants a different pixel format than 32-bit ARGB then things are gonna get complicated.
  3. Winit has some mac-specific WindowBuilder functions you might want to experiment with to see if they do anything useful. You can see where I use some of the Windows-specific functions here if you want to add a similar block for MacOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants