Detecting the presence of OpenGL?

Anyone aware of a means to dynamically detect if OpenGL is present and can therefore be used on a given MacOS X version on the specific machine it is running on?

What is the problem?

Every Mac running MacOS 10.9 or later should do OpenGL just fine.

deprecated in 10.14

I think we need a metal canvas.

Deprecated but not removed. Yet. The Catalina beta’s all still have it.

I’m wondering if this is fruitful since if your app requires OpenGL it wont start on a machine without OpenGL (at least thats what I would expect)
Effectively OpenGL would be a missing dependency

I suppose the other option would be to see if you can create an NSOpenGLContext and if that fails then its very likely OpenGL is not available in any way thats useful

I found building on 10.14.x with latest xojo 2019, OpenGL would not work as expected, namely a black screen. Building with with 2018rX worked though. (I think those were the versions)

We exposed all the metal classes and rewrote for that. It is a lot more complex than OpenGL, well the simple 2d stuff I was doing was. You needed a lot of classes just to get a triangle showing :stuck_out_tongue:

In total there are around 130 classes to support all features. There are some neat features as well, like iosurfaces to share memory with gpu between apps so you can load textures etc in a helper app and push to gpu.

As for detecting when to support OpenGL we just disabled for 10.14.x and above, forcing users to metal, which ran a lot better.

Geez you could probably pull that out and sell that in the Xojo world on its own for a decent price
At the very least speak at XDC about this undertaking
I’m impressed

The code isn’t mine to sell :frowning: and also don’t be too impressed, I didn’t expose all the functionality behind the classes, I just needed them as placeholders incase I needed to use them.

I would be happy to help anyone get started on it as well. The more people understanding it the better for when apple screw it all up in the next release. @Sam Rowlands got me started on the basics.

You guys checked the SceneKit classes in MBS Plugins?

Yes & No. My experience is based solely on using Metal as a display portal for Core Image rendering.

  1. It’s not x-plat.
  2. Guaranteed Metal support is quite limited, macOS 10.14 uses Metal only. for other versions you should support OpenGL as well.
  3. There are inconsistencies across Metal devices, I currently think that it’s down to different GPUs and certain color spaces.
  4. Metal’s co-ordinate system is different to OpenGL (absolute instead of relative).
  5. Certain functions in Metal crap their pants when encountering values outside of 0.0 ~ 1.0.
  6. Support for runtime shaders is going away, so all Metal shaders will have to be pre-compiled (which makes it much harder to write, test & improve custom shaders).
  7. You need to use Xcode to create Metal libraries (runtime shaders can be generated using Xojo code and declares).

Unless you’re specifically targeting Apple only devices, look at alternative solutions.