OpenGL added features from 1.0 through 3.0. At that point, it was decided that the older fixed-function API should be deprecated. In 3.1, many features were removed, and from 3.2 onward two profiles differentiated these differences: core and compatibility. Core profile only has the new API, and compatibility still supports the deprecated API. On most platforms, you can request a context compatible with any version of OpenGL, and the driver will attempt to do so. In Apple's implementation, there are 3 distinct versions you can request: 2.1 (legacy), 3.2 core, and 4.1 core. The core profiles do not implement legacy features, so you must choose between either the old fixed-function pipeline in 2.1, or the core functionality in one of the two later versions. Note that 4.1 core is fully backward compatible with 3.2 core.
Build with:
clang main.c -framework Cocoa -framework OpenGL
NSOpenGLPixelFormatAttribute glAttributes[] = {
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersionLegacy,
// NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
// NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
0,
};
When specifying your OpenGL attributes, you can request a specific context version with NSOpenGLPFAOpenGLProfile. The three valid values are: