0
我有以下代码:在Mac OS X与GLFW创建的OpenGL 3.3上下文10.9
void error_callback(int error, const char* description)
{
fputs(description, stderr);
}
int main(void)
{
// Initialise GLFW
if(!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
return -1;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
glfwSetErrorCallback(error_callback);
window = glfwCreateWindow(1024, 768, "Tutorial 16 - Shadows", NULL, NULL);
if(window == NULL){
//fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible. Try the 2.1 version of the tutorials.\n");
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
// Initialize GLEW
GLenum err;
glewExperimental = GL_TRUE; // Needed for core profile
if ((err = glewInit()) != GLEW_OK) {
std::cout << glewGetErrorString(err) << std::endl;
return -1;
}
...
}
的问题是,我收到以下消息:https://github.com/glfw/glfw/blob/master/src/nsgl_context.m#L101
而且,事实上,GLFW赢得如果不设置向前兼容性标志(在Mac OS X中),不给我一个OpenGL 3 +上下文。
这是为什么?在没有向前兼容性的情况下,有没有办法在Mac OS X 10.9中获得OpenGL 3+上下文?是OS X的OpenGL实现的限制还是GLFW的问题?
该请求将被拒绝在Mac OS X了3.x/4.x的上下文时隐式设置核心简档标志。返回的上下文始终是向前兼容的和核心配置文件,因为这是OS X支持的。 GLFW不会破坏这些[硬约束](http://www.glfw.org/docs/latest/window.html#window_hints_hard)。这样做会破坏应用程序的可移植性。 – elmindreda