Skip to content

Instantly share code, notes, and snippets.

@CanTheAlmighty
Last active March 10, 2024 08:43
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save CanTheAlmighty/ee76fbf701a61651fe439fcd6d25f41d to your computer and use it in GitHub Desktop.
Save CanTheAlmighty/ee76fbf701a61651fe439fcd6d25f41d to your computer and use it in GitHub Desktop.
DisplayLink for OSX
@CanTheAlmighty
Copy link
Author

This is based on the implementation done by Apple for MetalBasic3D example: https://developer.apple.com/library/ios/samplecode/MetalBasic3D/Introduction/Intro.html

I took that code and rewrote it in swift and moved into its own class, for easier integration when using Metal.

@iby
Copy link

iby commented May 4, 2017

Thanks for sharing! ❤️

@ryanfrancesconi
Copy link

I believe you want source.suspend() if you want to be able to restart the timer.

@MacyEleanorMay
Copy link

MacyEleanorMay commented Dec 23, 2019

And they say swift is easy and requires fewer lines of code than objc... I setup a DisplayLink in about 5 lines of code in ObJC.
Swift is for people who love writing complicated code

@MacyEleanorMay
Copy link

This is based on the implementation done by Apple for MetalBasic3D example: https://developer.apple.com/library/ios/samplecode/MetalBasic3D/Introduction/Intro.html

I took that code and rewrote it in swift and moved into its own class, for easier integration when using Metal.

The Code example you're referring to isn't using a DisplayLink

@adamnemecek
Copy link

Note that since mac 10.11 there's CVDisplayLinkSetOutputHandler which makes setting up of the callback simpler.

@iOSBrett
Copy link

iOSBrett commented Apr 8, 2023

And they say swift is easy and requires fewer lines of code than objc... I setup a DisplayLink in about 5 lines of code in ObJC.
Swift is for people who love writing complicated code

This is for the Mac though. CADisplayLink for iOS is easy in either Swift or ObjC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment