为什么我的OpenGL版本在Mac OS X上总是2.1?

RnM*_*Mss 15 opengl macos glfw

我在Mac OS X 10.8上使用GLFW 3.0,显卡是Intel HD Graphics 5000

我的OpenGL API版本是2.1,获得者

glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
Run Code Online (Sandbox Code Playgroud)

编译选项:

g++ ... -framework OpenGL -framework Cocoa -framework IOKit ...
Run Code Online (Sandbox Code Playgroud)

头:

#include <GLFW/glfw3.h>
#include <GL/glu.h>
Run Code Online (Sandbox Code Playgroud)

版本总是2.1,与报告的3.2不同.

https://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1085_Core.html

...

现在我的操作系统已经升级到10.9,OpenGL版本仍然是2.1.

它仍然无法编译GLSL 3.3,而Apple表示它支持4.1.

https://developer.apple.com/graphicsimaging/opengl/capabilities/index.html

我怎样才能使它工作?

RnM*_*Mss 24

在创建窗口之前,您需要添加"forward_compat"和"core_profile"提示.

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwCreateWindow(640, 480, "Hello World", NULL, NULL );
Run Code Online (Sandbox Code Playgroud)

  • 救了我的命(在解决这个问题之前我不会吃饭)。 (2认同)