Creating live wallpapers and screensavers with Metal/Metal2.

Hi,


I have some basic experience with Metal2 and Swift, I have managed to create some windowed sample apps with NSView and CAMetalLayer on macOS.

I'd like to create some live wallpapers and screensavers with Metal2.

I haven't found any related materials. Is there a tutorial somewhere? Or can someone please give me some hints?


Thanks in advance!

Wallpapers aren't animated so you can really "code" a wall paper (other than by setting an image). But you can write a screen saver using Metal.

I'm actually not very familiar with the screen saver API from the ScreenSaver.framework. Questions related to that are probalby better asked in the AppKit forum. I'm also more familiar with the ObjC APIs than Swift. But I'll try to give you some info on the Metal parts.

You can start by creating a 'Screen Saver' project in xcode. You'll need to implement the view provided to you in that project. Since that view needs to inherit from ScreenSaverView, you won't be albe to use MTKView for rendering. Instead, you'll need to return CAMetalLayer in your view's layerClass. This will enable to get Metal drawables from the view's layer. Then you can set up a RenderPassDescriptor with that drawable's texture and render to the drawablew which should show up on the screen once you present that drawable.

Thanks! Meanwhile I have also found the ScreenSaverView.


I have found something related to live wallpapers: https://stackoverflow.com/questions/16374959/how-to-write-interactive-wallpaper-for-mac-os-x-lion


I was browsing API references in xcode-beta 9, but I didn't find which NSWindow property could take the kCGDesktopWindowLevel value.

Creating live wallpapers and screensavers with Metal/Metal2.
 
 
Q