Qt& OpenGL OS X:Mountain Lion上的GLSL着色器版本仅为120 [英] Qt & OpenGL OS X: GLSL shader version only 120 on Mountain Lion

查看:80
本文介绍了Qt& OpenGL OS X:Mountain Lion上的GLSL着色器版本仅为120的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正通过遵循arcsynthesis教程,尝试将一些代码从固定功能OpenGL移至GLSL着色器.首先,我遇到了一个问题,即330版本不可用,在快速搜索后似乎很常见,但建议150版本应该可以正常工作.但是,除了120外,没有其他可用的GLSL着色器版本,对于10.8.4上的2013 Macbook Air,这是否正常?还是OS X下OpenGL + Qt 5的组合出现了一些怪异现象?

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?

https://developer.apple.com/library/ios/samplecode/GLEssentials/Introduction/Intro.html 如果在此处构建示例应用程序,则可以使用140和150(未尝试使用330,因为它需要重写着色器).有人知道这是否是与OpenGL,Qt5和OS X有关的特定问题吗?

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?

推荐答案

所以:

QGLFormat glFormat;
glFormat.setVersion(3, 2);
glFormat.setProfile(QGLFormat::CoreProfile);

// Set the default GL format to OpenGL 3.2 Core
QGLFormat::setDefaultFormat(glFormat);

这就是它需要工作的地方,这在文档中不太明显.这将给您150.如果将glFormat.setVersion(3, 2)更改为3,则将3更改为 以提供版本330,但在完成更多工作之前,我不知道它的可靠性.

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.

这篇关于Qt& OpenGL OS X:Mountain Lion上的GLSL着色器版本仅为120的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆