Jump to content
  • Advertisement
BlackJoker

Wrap macOS window using .Net Core 3.0

Recommended Posts

Hi,

Sorry if this is not correct branch, but I would like to ask how to wrap macOS window using .Net core 3.0

Which frameworks/dylibs I need to reference and which functions to p/invoke to make minimum framework for running window on macOS.

I dont want to use mono or Xamarin. I want to do it using pure .Net core 3.0

Didnt find any tutorial for this yet.

Could someone help me with this or at least point me to the right direction?

 

Share this post


Link to post
Share on other sites
Advertisement

It's not easy, take a look at how SDL works. The difficulty is that MacOS hides the main thread event loop in [NSApplication run], so it is pretty intrusive in your design. In my C++ wrapper, main() calls [NSApplication run], which blocks for the entire lifetime of the program, then gets a callback [applicationDidFinishLaunching], where I spawn a second thread which functions as the main thread of my engine, while the first thread handles event processing. You must also be very careful about what threads you are using. Most Cocoa windows/views require to be used from the main thread only, other threads must use [performSelectorOnMainThread] to run window/view methods on the main thread.

I would use this approach: write a wrapper similar to SDL with a C interface, then pinvoke that library from your managed language. Good luck, this is not an easy task and can take a long time to get it working correctly (my wrapper is 12 years old and still has some problems). You're probably better off finding an existing library that does this for you.

Share this post


Link to post
Share on other sites

OK, I managed to deal with it by writing custom macOS framework with C functions and callbacks and then p/invoke it in my engine on C# side. It was not so hard. Hopefully .Net core 3 allow to marshal macOS frameworks and dylibs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!