我一直在使用Mac OS X完成第五版OpenGL Superbible的代码,并且偶然发现了一个问题。 在我的顶点着色器中,我已经包含了版本号,即#version 130 。 但是,它无法编译错误ERROR: 0:1: '' : version '130' is not supported 。
信息:我在Mac OS版本10.8.5上使用Xcode,带有Intel HD Graphics 3000.它应该支持OpenGL 3.0版本,它与GLSL版本1.30相对应。
I've been following through the code of the fifth edition of the OpenGL Superbible using Mac OS X, and have stumbled across a problem. In my vertex shader, I have included the version number, being #version 130. However, it fails to compile with the error ERROR: 0:1: '' : version '130' is not supported.
Info: I am using Xcode on Mac OS version 10.8.5, with an Intel HD Graphics 3000. It should support OpenGL version 3.0, which corresponds with GLSL version 1.30.
最满意答案
除非您选择明确要求核心配置文件的像素格式,否则您将获得OpenGL 2.1实现。 有关如何执行此操作的详细信息,请参阅我对另一个问题的回答 ; 这是对OS X 10.7引入的CGL / NSOpenGL API的一个新变化,因此一些旧书可能无法记录它。
GPU支持的内容与实际获得的内容之间存在很大差异。 在许多其他平台上,不使用与OpenGL 3.2一起引入的窗口系统API的更改,您可以获得OpenGL 3.2+实现的所有功能以及默认情况下来自OpenGL 2.1及更早版本的旧功能(这称为兼容性配置文件)。
OS X不同,它不支持兼容性配置文件。 您可以获得传统的OpenGL 2.1实现或核心3.2(OS X 10.9中的3.3 / 4.1)实现,但您永远不能混合使用两者的功能。 此外,除非您修改代码以请求核心配置文件,否则默认情况下您将仅限于OpenGL 2.1。
Unless you select a pixel format that explicitly asks for a core profile, then you are going to get an OpenGL 2.1 implementation. See my answer to another question for more details on how to do this; this is a new change to the CGL / NSOpenGL APIs that was introduced with OS X 10.7, so some older books may not document it.
There is a big difference between what your GPU supports and what you actually get. On a lot of other platforms, without using changes to the window system APIs that were introduced alongside OpenGL 3.2, you can get all the features of an OpenGL 3.2+ implementation and the legacy things from OpenGL 2.1 and earlier by default (this is known as a compatibility profile).
OS X is different, it does not support compatibility profiles. You either get the legacy OpenGL 2.1 implementation or the core 3.2 (3.3/4.1 in OS X 10.9) implementation but you can never mix-and-match features from both. Furthermore, unless you modify your code to ask for a core profile, you will be limited to OpenGL 2.1 by default.
更多推荐
发布评论