Reputation: 406
I'm trying to learn OpenGL and the material is using #version 330 in shaders. I can compile it successfully, but when I try to run it, it complains Version 330 is not supported.
In my source code, I use free glut and OpenGL framework in Xcode. If I also include these two lines of code
glutInitContextVersion(3,1); glutInitContextFlags(GLUT_CORE_PROFILE);
it cannot be compiled.
My mac is MacBook Pro Mid 2012. It should support OpenGL4.1 according to apply.
So how can I compile version 330 shaders?
Upvotes: 4
Views: 5200
Reputation: 329
OS X requires that you request a 3.2 core profile in order to receive a 3.3 or later context. This is because 3.2 finally removed the functionally that was deprecated in 3.0.
So if you want to use a #version 330 shader then your code should look like this:
glutInitContextVersion(3,2);
glutInitContextFlags(GLUT_CORE_PROFILE);
EDIT Apparently X11 doesn't support OpenGL higher than 2.1 on OS X. As such, I suggest you switch to GLFW.
Upvotes: 1