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