deltacasttv/video-viewer

Add support for MacOS

Opened this issue · 6 comments

Only Windows and Linux are supported for now. It would be great to support MacOS.

After some investigations:

  • It looks like MacOS does not allow to create and manage GUI window in a non main thread. So the sample code throws some exceptions (that can be found in the Console logging app) : nextEventMatchingMask should only be called from the main thread. Using viewer.init in the main thread makes the error disappear.
  • MacOS has deprecated OpenGL so it now only supports forward-compatible core profile context for OpenGL 3.2 and above. As some OpenGL extensions are required, the core profile is not sufficient. Also the highest version of OpenGL on Mac is 4.1 but 4.3 is required.
    With these compatibility issues, the sample gives a black window rendering and error messages on the console such as:
...
Error: 135 groups_y [max 0]
Error: 240 groups_x [max 0]
Error: 135 groups_y [max 0]
Error: 240 groups_x [max 0]
...

It seems the best way would be to integrate Metal for MacOS. See glfw/glfw#1456 but it's not yet on master branch

here is a link about programming Metal in C++: https://developer.apple.com/videos/play/wwdc2022/10160/

Another alternative would be to migrate to Vulkan because GLFW now supports Vulkan on macOS via MoltenVK (https://www.glfw.org/docs/3.3/news.html#moltenvk_33).

GLFW Vulkan guide: https://www.glfw.org/docs/3.3/vulkan_guide.html

I’m not sure how stable or usable this is, but has anyone fully explored it yet? https://github.com/openglonmetal/MGL