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

Add support for game window embedding on macOS #11453

Open
jrapf32 opened this issue Dec 30, 2024 · 6 comments
Open

Add support for game window embedding on macOS #11453

jrapf32 opened this issue Dec 30, 2024 · 6 comments
Labels
implementer wanted This proposal can probably be implemented, if there was a hero to do it platform:macos topic:editor topic:porting

Comments

@jrapf32
Copy link

jrapf32 commented Dec 30, 2024

Describe the project you are working on

I'm working on a game that needs object selection, and it's getting tiresome having to switch to the editor, hit the 2d button in the game tab, and then switch back.

Describe the problem or limitation you are having in your project

Currently, "Game embedding is not available on your OS." People use Macs to make games, which could be a problem.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Adding it would help.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

It should work like all other platforms.

If this enhancement will not be used often, can it be worked around with a few lines of script?

If this is not implemented, people can still use Cmd+Tab to switch between windows, but it will be inconvenient.

Is there a reason why this should be core and not an add-on in the asset library?

This functionality is built into the editor and can't be changed by an addon.

@tetrapod00
Copy link

The need for this is known, and there are some ideas on how to accomplish it. See comments in the original PR implementing the feature: godotengine/godot#99010 (comment) and godotengine/godot#99010 (comment).

@Calinou Calinou changed the title MacOS Window Embedding Add support for game window embedding on macOS Jan 2, 2025
@akien-mga akien-mga added the implementer wanted This proposal can probably be implemented, if there was a hero to do it label Mar 11, 2025
@ettiSurreal
Copy link

ettiSurreal commented Mar 11, 2025

Since the proposal text is vague and it gets many views based on the reactions, here's a more thorough explanation.

The reason embedding doesn't work on MacOS, isn't captured by screen-capturing applications, is disabled in single window mode, and often runs into window-related edge cases (like window-changing hotkeys from the system), is because it was implemented by having the game window be the parent of the editor and making it borderless. So in practice this means that it's simply a borderless window glued to the editor.

Potentially all of this could be solved by re-implementing embedding by directly getting the Vulkan/Metal frame buffer from the game process (or a hidden window if that's not possible?), and displaying it over a TextureRect(?) in the Game workspace. Someone will also have to figure out how to account for Input and Audio, the latter should also preferably get emitted by the editor window so recording it would also capture the audio.
Due to obvious benefits this should be the "default" way embedding should work where possible, with the sub-window approach being a fallback when it's not supported. This also means that if possible the implementation should be kept the least vendor specific.
Some pointers I've seen that someone could use as a starting point:
godotengine/godot#99010 (comment)
godotengine/godot#99010 (comment)

(this is all just information I collected from people smarter than me, please correct this if I got anything wrong)

@Nordup
Copy link

Nordup commented Mar 17, 2025

I've got a working macOS game embedding on my fork
https://github.com/thegatesbrowser/godot/blob/9fe18c2a83ca47f3ca777ce3e7d1f83f05fbdf43/drivers/vulkan/rendering_device_driver_vulkan.cpp#L1437

It uses IOSurface with Vulkan VK_EXT_metal_objects extension
Main process exports IOSurface and child process imports it and copies it's swapchain into that shared texture

I use some ipc library to handle interaction and sending games input

I can work on porting the code to godot with the help of other contributors
I'm waiting for this feature anyway so I don't have to deal with maintaining it and solving merge conflicts :)

@nubels
Copy link

nubels commented Mar 24, 2025

I've got a working macOS game embedding on my fork https://github.com/thegatesbrowser/godot/blob/9fe18c2a83ca47f3ca777ce3e7d1f83f05fbdf43/drivers/vulkan/rendering_device_driver_vulkan.cpp#L1437

It uses IOSurface with Vulkan VK_EXT_metal_objects extension Main process exports IOSurface and child process imports it and copies it's swapchain into that shared texture

I use some ipc library to handle interaction and sending games input

I can work on porting the code to godot with the help of other contributors I'm waiting for this feature anyway so I don't have to deal with maintaining it and solving merge conflicts :)

I wanted to try your implementation of game embedding so I compiled Godot from the master branch of your fork but for me, it's Godot 4.3 and there's no embedding. I don't know if I missed something

@Nordup
Copy link

Nordup commented Mar 26, 2025

I wanted to try your implementation of game embedding so I compiled Godot from the master branch of your fork but for me, it's Godot 4.3 and there's no embedding. I don't know if I missed something

Yeah, sorry for not being clear
My implementation doesn't work in the editor

I'm using it from within the application I'm developing
To launch child processes and display them in the main app

@nubels
Copy link

nubels commented Mar 30, 2025

I wanted to try your implementation of game embedding so I compiled Godot from the master branch of your fork but for me, it's Godot 4.3 and there's no embedding. I don't know if I missed something

Yeah, sorry for not being clear My implementation doesn't work in the editor

I'm using it from within the application I'm developing To launch child processes and display them in the main app

Ah okay, I see. :)

On another note, since you mentioned the help of other contributors, maybe you can get in touch with @stuartcarnie and @nevyn? They mentioned they also want to look into game embedding on mac. :)

godotengine/godot#99010 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementer wanted This proposal can probably be implemented, if there was a hero to do it platform:macos topic:editor topic:porting
Projects
None yet
Development

No branches or pull requests

7 participants