C++ 在Mac OS X 10.9中使用GLFW创建OpenGL 3.3上下文

C++ 在Mac OS X 10.9中使用GLFW创建OpenGL 3.3上下文,c++,macos,opengl,opengl-es,glfw,C++,Macos,Opengl,Opengl Es,Glfw,我有以下代码: 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(GLF

我有以下代码:

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;
}

...

}
void error\u回调(int error,const char*description)
{
FPUT(描述、标准);
}
内部主(空)
{
//初始化GLFW
如果(!glfwInit())
{
fprintf(stderr,“未能初始化GLFW\n”);
返回-1;
}
glfwWindowHint(GLFW_样本,4个);
glfwWindowHint(GLFW_上下文_版本_专业,3);
glfwWindowHint(GLFW_上下文_版本_小调,3);
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT,GL_TRUE);
glfwWindowHint(GLFW_OPENGL_配置文件、GLFW_OPENGL_核心配置文件);
//打开窗口并创建其OpenGL上下文
glfwSetErrorCallback(错误回调);
window=glfwCreateWindow(1024768,“教程16-阴影”,NULL,NULL);
如果(窗口==NULL){
//fprintf(stderr,“无法打开GLFW窗口。如果您有英特尔GPU,则它们与3.3不兼容。请尝试教程的2.1版本。\n”);
glfwTerminate();
返回-1;
}
glfwMakeContextCurrent(窗口);
//初始化GLEW
肩胛盂;
glewExperimental=GL_TRUE;//核心配置文件需要
如果((err=glewInit())!=GLEW\u正常){

这实际上是正确的行为,如中所定义

Mac OS X不支持OpenGL 3.X/4.X的兼容性配置文件,因此您必须请求核心(或前向兼容)上下文。这意味着您在Mac上针对OpenGL 3.X/4.X编程时将无法使用任何不推荐的函数


在Mac OS x上请求3.x/4.x上下文时,可能值得在中发出功能请求以隐式设置核心配置文件标志。

这实际上是正确的行为,如中所定义

Mac OS X不支持OpenGL 3.X/4.X的兼容性配置文件,因此您必须请求核心(或前向兼容)上下文。这意味着您在Mac上针对OpenGL 3.X/4.X编程时将无法使用任何不推荐的函数


在Mac OS x上请求3.x/4.x上下文时,可能值得在中发出功能请求以隐式设置core profile标志。

该请求将被拒绝。返回的上下文始终是前向兼容的core profile,因为这是OS x支持的。GLFW不会破坏这些。这样做会破坏应用程序端口可移植性。该请求将被拒绝。返回的上下文始终是前向兼容的和核心配置文件,因为这是OS X支持的。GLFW不会破坏这些。这样做会破坏应用程序的可移植性。