15

I'm following the arcsynthesis tutorials on OpenGL 3.3 using 10.8 Mountain Lion and when building the project it compiles and runs the shaders using GLSL version 3.30, however even in the core profile on Mac OS 10.8 I shouldn't have GLSL 3.30 support - only 1.50 (as highlighted in the picture)

Is anybody able to explain how I have managed to achieve this black magic?

Mohsen Safari
  • 6,669
  • 5
  • 42
  • 58
LiarWithFire
  • 151
  • 1
  • 4
  • In fact, with some further testing it works all the way up to GLSL 4.10. Only on trying 4.20 does it fail to compile the shaders... – LiarWithFire Aug 15 '12 at 05:37
  • Maybe the shader compiler doesn't properly recognise the higher shader languages. Have you tried using a 330-specific feature? – Oskar Aug 15 '12 at 05:38
  • 1
    As far as I am aware, layout(location = 0) is only included in GLSL 3.3 and above. – LiarWithFire Aug 15 '12 at 05:44
  • Ah, well then the exact same quirk occurs on my computer! :-) – Oskar Aug 15 '12 at 05:52
  • 2
    My guess is that Apple may have been working on some compiler-based upgrades and left them in by accident. Or that the lower-level implementation of the compiler compiled it. Do you get GL 3.3-specific function pointers, like `glQueryCounter` (there's [a bug](https://bitbucket.org/alfonse/unofficial-opengl-sdk/issue/39/glvertexattribdivisor-not-available-in-a#comment-1813156) that prevents `glVertexAttribDivisor` from working, which will be fixed in the next release of the SDK). – Nicol Bolas Aug 15 '12 at 09:31
  • 1
    No glQueryCounter doesn't work - it seems to be just GLSL that has bumped up some versions... – LiarWithFire Aug 15 '12 at 10:13
  • @LiarWithFire This post is a little bit old, but I'm trying to run the same set of tutorials. Are you still around? If so, how did you manage to have these running on OS X? I get this error when I try to use freeglut: http://stackoverflow.com/questions/12229211/issues-with-freeglut-on-mac-os-snow-leopard-it-builds-fine-via-macports – Ricardo Sanchez-Saez Jul 30 '13 at 20:02

1 Answers1

8

OS X 10.8 still only support OpenGL 3.2, but with some 3.3 features such as specifying attribute location (#extension GL_ARB_explicit_attrib_location : enable). The shader compiler accepts versions up to 4.10. They might have left it there for compatibility or (SPECULATION) they originally intended to support 4.1.

This is at least my conclusion after a few weeks with 10.8.

EDIT: Looks like the 4.10 speculations were spot on. 10.9-10.12 support up to version 4.10. I guess they wanted to spend resources on their Metal api rather than moving forward and get compute shaders in..

Grimmy
  • 3,992
  • 22
  • 25
  • 1
    It should be noted that if `#extension GL_ARB_explicit_attrib_location : enable` actually works, it's off-spec because OpenGL doesn't advertise GL_ARB_explicit_attrib_location. Either that, or Apple's [OpenGL extension page is out of date.](https://developer.apple.com/graphicsimaging/opengl/capabilities/) – Nicol Bolas Dec 01 '12 at 22:42
  • 1
    Yes. I can verify that this extension works on both ATI and Nvidia in 10.7 and 10.8. Figured it out by accident when porting deferred shaders to GLSL 1.5 / OS X having to support specifying out locations in the fragment shader. (rendering to multiple FBO attachments) Already learned the hard way how important this is, and was thrilled I didn't have to fix it the hard way. – Grimmy Dec 03 '12 at 03:56