Search code examples
c++macosopenglglsl

GLSL version 130 on Mac OS X causes error


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.


Solution

  • 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.