Qt & OpenGL OS X: GLSL shader version only 120 on Mountain Lion

若如初见. 提交于 2019-12-10 10:49:04

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!