我一直在 Xcode 中使用 GLFW 2 开发一个 OpenGL 项目,一切都运行良好。我能够创建一个 3.2 OpenGL 上下文,并渲染所有内容。
但是,昨天我安装了 GLFW3 库并进行了建议的更正。现在我根本无法创建 3.2 上下文,它总是返回 3.0.3 上下文。我做错了什么?
我在 glfw 之前包含了 glew 标题
这是我的初始化代码:
if(!glfwInit()){
std::cout << "ERROR IN glfwInit()" << std::endl;
return;
}
mWindow = glfwCreateWindow(mWidth, mHeight, "GLFW Renderer", NULL, NULL);;
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
if(!mWindow){
std::cout << "ERROR IN glfwOpenWindow" << std::endl;
glfwTerminate();
return;
}
/* Make the window's context current */
glfwMakeContextCurrent(mWindow);
int major, minor, rev;
glfwGetVersion(&major, &minor, &rev);
std::cout << "OpenGL " << major << "." << minor << "." << rev << std::endl;
glewExperimental = GL_TRUE;
if(glewInit() != GLEW_OK){
std::cout << "ERROR INITIALIZING GLEW" << std::endl;
return;
}
glViewport(0, 0, mWidth, mHeight);
编辑:将 GLFW_CONTEXT_VERSION_MINOR 更改为 2