Appleshell
Appleshell

Reputation: 7388

Can't set GL flags with GLFW

Trying to set one or more of the following OpenGL flags:

glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

makes glfwOpenWindow fail. Why is this the case?

[Edit] It seems to work with MAJOR=3 and MINOR=2, but the Notebook the code runs on (MacBook Retina Mid2012) is possible to run up to OpenGL 4.1 (Intel HD 4000 has OpenGL 4.0, Nvidia GT 650M has 4.1). [/Edit]

Also, while it might be unrelated, glfwGetGLVersion returns 0 for all three parameters.

Full example code below:

int main(int argc, char * argv[])
{
    if(!glfwInit()) {
        return EXIT_FAILURE;
    }

    glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE);
    //glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    //glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
    //glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    //glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

    {
        int *major = new int, *minor = new int, *rev = new int;
        glfwGetGLVersion(major, minor, rev);
        std::cout << *major << " " << *minor << " " << *rev << std::endl;
        delete major;
        delete minor;
        delete rev;
    }

    if(!glfwOpenWindow(512,512,
                       8,8,8,
                       8,24,8,
                       GLFW_WINDOW)) {
        return EXIT_FAILURE;
            // APPLICATION EXITS HERE IF ONE OF THE FLAGS ARE SET.
    }

    while (glfwGetWindowParam(GLFW_OPENED)) {   
        glClear(GL_COLOR_BUFFER_BIT);
        glfwSwapBuffers();
    }

    glfwTerminate();
    return 0;
}

Upvotes: 2

Views: 240

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473352

If it's a MacBook, you're probably running OSX. And while your graphics card has the ability to support OpenGL 4.x, OSX only supports OpenGL 3.2.

Upvotes: 6

Related Questions