# Detecting the presence of OpenGL?

**URL:** <https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092>\
**Category:** General\
**Created:** [September 3, 2019, 3:54pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092 "2019-09-03T15:54:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ed\_Kleban](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/a8b319/32.png) [@Ed\_Kleban](https://forum.xojo.com/u/Ed_Kleban)\
**Post date:** [September 3, 2019, 3:54pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/1 "2019-09-03T15:54:49Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [September 3, 2019, 5:00pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/2 "2019-09-03T17:00:36Z")

</div>

What is the problem?

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

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [September 3, 2019, 5:14pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/3 "2019-09-03T17:14:21Z")

</div>

deprecated in 10.14

---

<div class="post-metadata">

**Author:** ![Brian\_O\_Brien](https://forum.xojo.com/user_avatar/forum.xojo.com/brian_o_brien/32/20096_2.png) [@Brian\_O\_Brien](https://forum.xojo.com/u/Brian_O_Brien)\
**Post date:** [September 4, 2019, 9:08pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/4 "2019-09-04T21:08:54Z")

</div>

I think we need a metal canvas.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [September 4, 2019, 11:28pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/5 "2019-09-04T23:28:24Z")

</div>

> [@452581:@Dave S](#):
>
> deprecated in 10.14

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

---

<div class="post-metadata">

**Author:** ![Norman\_Palardy](https://forum.xojo.com/user_avatar/forum.xojo.com/norman_palardy/32/169_2.png) [@Norman\_Palardy](https://forum.xojo.com/u/Norman_Palardy)\
**Post date:** [September 4, 2019, 11:39pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/6 "2019-09-04T23:39:36Z")

</div>

> [@452571:@Ed Kleban](#):
>
> 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?

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](https://developer.apple.com/documentation/appkit/nsopenglcontext?language=objc) and if that fails then its very likely OpenGL is not available in any way thats useful

---

<div class="post-metadata">

**Author:** ![Graham\_Busch](https://forum.xojo.com/user_avatar/forum.xojo.com/graham_busch/32/21827_2.png) [@Graham\_Busch](https://forum.xojo.com/u/Graham_Busch)\
**Post date:** [September 5, 2019, 3:10am UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/7 "2019-09-05T03:10:56Z")

</div>

> [@452819:@Bob Keeney](#):
>
> Deprecated but not removed. Yet. The Catalina beta’s all still have it.

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 😛

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.

---

<div class="post-metadata">

**Author:** ![Norman\_Palardy](https://forum.xojo.com/user_avatar/forum.xojo.com/norman_palardy/32/169_2.png) [@Norman\_Palardy](https://forum.xojo.com/u/Norman_Palardy)\
**Post date:** [September 5, 2019, 3:42am UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/8 "2019-09-05T03:42:57Z")

</div>

> [@452833:@Graham Busch](#):
>
> We exposed all the metal classes and rewrote for that.

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

---

<div class="post-metadata">

**Author:** ![Graham\_Busch](https://forum.xojo.com/user_avatar/forum.xojo.com/graham_busch/32/21827_2.png) [@Graham\_Busch](https://forum.xojo.com/u/Graham_Busch)\
**Post date:** [September 5, 2019, 5:02am UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/9 "2019-09-05T05:02:16Z")

</div>

The code isn’t mine to sell ☹ 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.

---

<div class="post-metadata">

**Author:** ![Christian\_Schmitz](https://forum.xojo.com/user_avatar/forum.xojo.com/christian_schmitz/32/158_2.png) [@Christian\_Schmitz](https://forum.xojo.com/u/Christian_Schmitz)\
**Post date:** [September 5, 2019, 5:45am UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/10 "2019-09-05T05:45:08Z")

</div>

You guys checked the SceneKit classes in MBS Plugins?

---

<div class="post-metadata">

**Author:** ![Sam\_Rowlands](https://forum.xojo.com/user_avatar/forum.xojo.com/sam_rowlands/32/265_2.png) [@Sam\_Rowlands](https://forum.xojo.com/u/Sam_Rowlands)\
**Post date:** [September 5, 2019, 6:17am UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/11 "2019-09-05T06:17:03Z")

</div>

> [@452807:@Brian O'Brien](#):
>
> I think we need a metal canvas.

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.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:04pm UTC](https://forum.xojo.com/t/detecting-the-presence-of-opengl/50092/12 "2021-04-29T16:04:36Z")

</div>


