本文介绍了Mavericks下的OpenGL 4.1(?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将MacBook Pro升级到包括Xcode在内的Mavericks(MacOS 10.9).根据Apple的"OpenGL功能表",此版本具有支持对于OpenGL 4.1,但是对glGetString(GL_VERSION)的调用返回"1.2"和我的GLSL以"#version 330"开头的3.30着色器拒绝加载,并说版本不受支持.

I've just upgraded my MacBook Pro to Mavericks (MacOS 10.9), including Xcode.According to Apple's "OpenGL Capabilities Table", this version has supportfor OpenGL 4.1, but a call to glGetString(GL_VERSION) returns "1.2" and my GLSL3.30 shader, which begins with "#version 330" refuses to load, saying thatversion is not supported.

我需要对Mavericks进行一些操作以启用4.1支持吗?

Do I need to do something to Mavericks to enable 4.1 support?

推荐答案

在OS X上使用较低级别的API之一请求像素格式时,需要在属性列表中添加以下内容,才能使用核心资料:

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:

  kCGLPFAOpenGLProfile,     kCGLOGLPVersion_3_2_Core

NSOpenGL:

  NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core

现在,尽管特定常量名为 ... >,但实际上意味着请求一个上下文,该上下文删除所有不推荐使用的功能并至少支持OpenGL 3.2(换句话说就是核心个人资料).您可以使用相同的常量获得4.1或3.3上下文;老实说,在常量中包含实际版本号可能是一个糟糕的选择.

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.

如果您在请求像素格式时未指定此选项,则OS X将分别为您提供kCGLOGLPVersion_Legacy或NSOpenGLProfileVersionLegacy.这将限制您使用OpenGL 2.1功能.

If you do not specify this when you request your pixel format, OS X will give you kCGLOGLPVersion_Legacy or NSOpenGLProfileVersionLegacy respectively. And this will limit you to OpenGL 2.1 functionality.

如果您使用的是更高级别的框架,那么您将需要查阅您的API参考.但是请注意,在OS X上,您必须具有 core 配置文件上下文,才能访问比OpenGL 2.1更高的任何内容.

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.

这篇关于Mavericks下的OpenGL 4.1(?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 02:07