简体   繁体   中英

Creating a virtual display on macOS, programmatically

I am looking for the ability to create a virtual display on macOS, preferably using Electron/Node.js or native macOS development if that's the only resort.

I would like to create a virtual display that functions just like a real one, can be re-arranged etc.

Basically, imagine what happens when you plug in an HDMI cable into your computer - exactly the same.

I looked into:

But couldn't find any useful information - it's mostly read-only.

I don't know of any library that would give you this off-the-shelf (and anyway StackOverflow is not for library recommendations).

If you were to implement it yourself, you would need to implement a virtual display driver. To do this you will need to learn about IOKit, IODisplay, IOFramebuffer and (possibly) IOGraphicsLib. It's a pretty complicated project and you'll need to know C++.

See IOKit in Apple's documentation to get an idea of what you're looking at.

Depending on what you're trying to do, it may be worthwhile looking at how VNC works, in particular the Remote Frame Buffer protocol.

There is undocumented API in CoreGraphics to create virtual displays. It works as one can expect, from Objective-C, based on the API (dumped in https://github.com/w0lfschild/macOS_headers/tree/master/macOS/Frameworks/CoreGraphics/1348/ ). At least in macOS 10.15, no idea about macOS 11. But, as mentioned, it is undocumented and will thus possibly change without warning or might cause the machine to crash if used incorrectly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM