문제

I have the following code:

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

...

}

The problem is that I'm receiving the following message: https://github.com/glfw/glfw/blob/master/src/nsgl_context.m#L101

And, indeed, GLFW won't give me a OpenGL 3+ context without setting the forward-compatibility flag (in Mac OS X).

Why is that? Is there any way to get a OpenGL 3+ context in Mac OS X 10.9 without forward-compatibility? Is it a limitation of OpenGL implementation for OS X or a problem of GLFW?

도움이 되었습니까?

해결책

This is actually the correct behavior, as defined in the OpenGL Programming Guide for Mac.

Mac OS X simply does not support the compatibility profile for OpenGL 3.x/4.x, so you must request a core (or forward-compatible) context. This implies that you will not be able to use any deprecated functions when programming against OpenGL 3.x/4.x on a Mac.

It might be worth to make a feature request in the GLFW issue tracker to set the core profile flag implicitly when requesting a 3.x/4.x context on Mac OS X.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top