5
votes

I've been following through the code of the fifth edition of the OpenGL Superbible using Mac OS X, and have stumbled across a problem. In my vertex shader, I have included the version number, being #version 130. However, it fails to compile with the error ERROR: 0:1: '' : version '130' is not supported.

Info: I am using Xcode on Mac OS version 10.8.5, with an Intel HD Graphics 3000. It should support OpenGL version 3.0, which corresponds with GLSL version 1.30.

2
You will get, at a minimum, a 3.2 (core profile) context on 10.8 or a 3.3 context on Mavericks. i.e., GLSL 1.50 or 3.30.Brett Hale
@BrettHale any idea why it's giving me this error, then?Fitzy

2 Answers

7
votes

Unless you select a pixel format that explicitly asks for a core profile, then you are going to get an OpenGL 2.1 implementation. See my answer to another question for more details on how to do this; this is a new change to the CGL / NSOpenGL APIs that was introduced with OS X 10.7, so some older books may not document it.

There is a big difference between what your GPU supports and what you actually get. On a lot of other platforms, without using changes to the window system APIs that were introduced alongside OpenGL 3.2, you can get all the features of an OpenGL 3.2+ implementation and the legacy things from OpenGL 2.1 and earlier by default (this is known as a compatibility profile).

OS X is different, it does not support compatibility profiles. You either get the legacy OpenGL 2.1 implementation or the core 3.2 (3.3/4.1 in OS X 10.9) implementation but you can never mix-and-match features from both. Furthermore, unless you modify your code to ask for a core profile, you will be limited to OpenGL 2.1 by default.

0
votes

In macOS, the OpenGL version supported in linked to the system version. The most advanced supported version is OpenGL 4.1 since OS X 10.9 (Mavericks).

Furthermore, OpenGL is now deprecated since macOS 10.14 (Mojave), you have to use the Metal framework or MoltenVK (a Vulkan wrapper for OS X). Vulkan is the successor of OpenGL.

Useful links:

https://developer.apple.com/videos/play/wwdc2018/604/

Develop using OpenGL 4.x on OSX Big Sur