I'm trying to move some code from the fixed function OpenGL to GLSL shaders, by following along with the arcsynthesis tutorials. First I ran into the issue that version 330 isn't available which after a quick search seemed common, but the recommendation is that 150 should work fine. However, aside from 120 there's no other GLSL shader versions available, is this normal for a 2013 Macbook Air on 10.8.4? Or is there some weirdness going on with the combination of OpenGL + Qt 5 under OS X?
EDIT: https://developer.apple.com/library/ios/samplecode/GLEssentials/Introduction/Intro.html if I build the sample app there I can use 140 and 150 (not tried 330 as it requires shader rewrites). Does anyone know if this is a specific issue related to OpenGL, Qt5 and OS X?
So:
QGLFormat glFormat;
glFormat.setVersion(3, 2);
glFormat.setProfile(QGLFormat::CoreProfile);
// Set the default GL format to OpenGL 3.2 Core
QGLFormat::setDefaultFormat(glFormat);
That's what's needed for it to work, which is helpfully not obvious in the documentation. That'll give you 150. If you changed the glFormat.setVersion(3, 2) to 3, 3 it seems to give version 330 but I have no idea how reliable this will be until I've done some more work.
来源:https://stackoverflow.com/questions/19277730/qt-opengl-os-x-glsl-shader-version-only-120-on-mountain-lion