【发布时间】:2014-03-06 02:48:02
【问题描述】:
我有以下代码:
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
事实上,如果不设置前向兼容标志(在 Mac OS X 中),GLFW 不会给我一个 OpenGL 3+ 上下文。
这是为什么呢?有没有办法在没有前向兼容性的情况下在 Mac OS X 10.9 中获取 OpenGL 3+ 上下文?是 OS X 的 OpenGL 实现的限制还是 GLFW 的问题?
【问题讨论】:
标签: c++ macos opengl opengl-es glfw