I've just upgraded my MacBook Pro to Mavericks (MacOS 10.9), including Xcode. According to Apple's "OpenGL Capabilities Table", this version has support for OpenGL 4.1, but a call to glGetString(GL_VERSION) returns "1.2" and my GLSL 3.30 shader, which begins with "#version 330" refuses to load, saying that version is not supported.
Do I need to do something to Mavericks to enable 4.1 support?
http://support.apple.com/kb/HT5942
the site title is "Mac computers: OpenCL and OpenGL support in OS X Mavericks - Learn about the OpenGL and OpenCL versions that are supported by your computer in OS X Mavericks."
If you are using SDL as your high level API there are a number of things you need to do to get 4.1 support.
First of all make sure you have SDL2 2.0.1 (or later I guess). For instance using brew:
Secondly, you need to specifically tell SDL to request a core profile like so
Thirdly a quirk in how a core profile is requested on the mac actually requires you to request 3.2 to get 4.1 (!). I think this has been fixed in the SDL2 repository but not been released yet.
Use the OpenGL library GLFW the latest version is 3.0.4... right after you initialize glfw init
after you initialize glfwInit() include these 4 lines of code. these four line of code will enable you to use the highest version supported by you OS. on mac its opengl 4.1
then create your window.
check to make sure it was created.
then make it you current window using the following.
after you make it your cureent window all thats left to be done is to create you main loop.
make sure you includ glfwPollEvents(); in the loop this makes it possible to use the close botton to quit the window. if you having trouble compiling the library in xcode just message me on here and i will send you a copy of the library.
When you request your pixel format using one of the lower-level APIs on OS X, you need to add the following to your attribute list in order to use a core profile:
CGL:
NSOpenGL:
Now, while the particular constant is named ...
3_2Core
, what it actually means is request a context that removes all deprecated features and supports at least OpenGL 3.2 (a core profile, in other words). You can get a 4.1 or 3.3 context using this same constant; in all honesty, including an actual version number in the constant was probably a poor choice.If you do not specify this when you request your pixel format, OS X will give you
kCGLOGLPVersion_Legacy
orNSOpenGLProfileVersionLegacy
respectively. And this will limit you to OpenGL 2.1 functionality.If you are using a higher-level framework, then you will need to consult your API reference. However, be aware that on OS X you must have a core profile context to access anything newer than OpenGL 2.1.
If you're using LWJGL (as of version 2.90), there's a mild gotcha in the javadoc header of ContextAttribs:
I struggled a long time on this, and finally succeeded on using any glsl version supported by the graphics card.
There are several main points:
for example, as pointed out by @kanthonye, if you are using glfw, and use gl version 3.2, these lines are needed: