macos OS X 上的 GLUT 和 OpenGL 3.2 核心配置文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11259328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 09:17:43  来源:igfitidea点击:

GLUT on OS X with OpenGL 3.2 Core Profile

macosopenglglslglutosx-mountain-lion

提问by Mortennobel

Is it possible to use GLUT on OS X Lion or OS X Mountain Lion using core profile (so I can use GLSL 1.50)?

是否可以使用核心配置文件在 OS X Lion 或 OS X Mountain Lion 上使用 GLUT(因此我可以使用 GLSL 1.50)?

Can I use the built in GLUT or do I need to use a third-part library such as FreeGLUT?

我可以使用内置的 GLUT 还是需要使用第三方库,例如 FreeGLUT?

And is there any simple 'Hello world' applications available for OS X with either an XCode project or a make-file?

是否有任何简单的“Hello world”应用程序可用于带有 XCode 项目或生成文件的 OS X?

回答by Michael Dorner

You need at least Mac OS X Lion (OS X 10.7 or higher) for the basic support of OpenGL 3.2. To use the OpenGL 3.2 Core Profile, just add

您至少需要 Mac OS X Lion(OS X 10.7 或更高版本)才能基本支持 OpenGL 3.2。要使用 OpenGL 3.2 核心配置文件,只需添加

glutInitDisplayMode(GLUT_3_2_CORE_PROFILE | ... | ...);

in your main-function. You can check it by

在您的main功能中。你可以通过

std::printf("%s\n%s\n", 
        glGetString(GL_RENDERER),  // e.g. Intel HD Graphics 3000 OpenGL Engine
        glGetString(GL_VERSION)    // e.g. 3.2 INTEL-8.0.61
        );

回答by flyx

GLUT does not support OpenGL 3.2, as it provides no functionality to specify the desired OpenGL context version. Also, GLUT's functionality relies on APIs that are not available with the OpenGL 3.2 Core Profile.

GLUT 不支持 OpenGL 3.2,因为它不提供指定所需 OpenGL 上下文版本的功能。此外,GLUT 的功能依赖于 OpenGL 3.2 核心配置文件不可用的 API。

You have to switch to FreeGLUT or GLFW.

您必须切换到 FreeGLUT 或 GLFW。

回答by user4536283

flyx is wrong, OpenGL 3.2 is the version that added core and compatibility profiles (not 3.3). However, Apple just doesn't support compatibility profiles at all (no reason, they just don't). GLUT comes in xcode as a framework and you can use it that way. So you can do it in a completely non-standard, platform specific way.

flyx 是错误的,OpenGL 3.2 是添加了核心和兼容性配置文件的版本(不是 3.3)。但是,Apple 根本不支持兼容性配置文件(没有理由,他们就是不支持)。GLUT 作为框架在 xcode 中出现,您可以这样使用它。因此,您可以以完全非标准的、特定于平台的方式来完成。