NULL returned from glfwCreateWindow when setting OpenGL context hints

I’m getting NULL returned from glfwCreateWindow iff I set a core profile. I’ve tried a bunch of them. This is for an application that I wrote a long time ago, and am getting around to upgrading it to OpenGL 3.2+ … so it’s a work in progress. If I turn on the core profile, I imagine it would work or complain about deprecated things (if there are any). I created a handy-dandy list of deprecated functions (attached) which I used with grep -f to find all of the deprecated functions, and have commented out or eliminated them and foisted more GL3+ friendly alternatives upon the program.

I am using GLEW to handle any extensions, but am not using extensions in my program right now.

I am wondering a few things:

  1. If I link in function calls or whatnot that are deprecated, would this cause glfwCreateWindow to return NULL?
  2. Is there a way to check and see WHY glfwCreateWindow returned NULL?

Here’s my link line’s list of libraries, if it’s useful:

-L/usr/X11/lib -logg -lvorbis -ljpeg -lpng -lsndfile -lportaudio -lpthread -lfreetype -lGLEW libs/linux/lib/liblua.a /usr/local/lib/libglfw3.a -ldl -lGL -lX11 -lXrandr -lXi -lXxf86vm -lXinerama -lXcursor

This is the pertinent code that leads up to where I get the NULL pointer from GLFW:


printf("Setting up window hints.
");
        glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing
printf("Set AA.
");
        glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);

#ifdef USE_GL3_HINTS
//  Any of these, when set, causes glfwCreateWindow to return false.
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
printf("Set major version.
");
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
printf("Set minor version.
");
        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
//printf("Set COMPAT hint.
");
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //We don't want the old OpenGL

#endif




        GLFWmonitor* monitor = glfwGetPrimaryMonitor();

printf("Now creating window.  Primary monitor info at %p.
", monitor);  fflush(stdout);
        /// \bug  What if I want to run on 2 or more monitors??
        glfwCtx = glfwCreateWindow(width, height, "My Title", fullscreen ? monitor : NULL, NULL);

        if(glfwCtx == NULL)
        {
printf("GLFW window context was NULL.
"); fflush(stdout);
                glfwTerminate();
                exit(EXIT_FAILURE);
        }

Now, keep in mind, this application works (fairly) well when I don’t have USE_GL3_HINTS defined; glfwCreateWindow only returns NULL when USE_GL3_HINTS is defined.

Thank you

Rob

Have you checked to see if your implementation actually supports OpenGL 3.2?

  1. If I link in function calls or whatnot that are deprecated, would this cause glfwCreateWindow to return NULL?

I’m more concerned with the fact that you think it could. Especially since OpenGL is dynamically loaded, so it’s basically impossible for GLFW to know what functions you’re going to pull from the OpenGL DLL.

Not unless you think GLFW is going to decompile your application :wink:

  1. Is there a way to check and see WHY glfwCreateWindow returned NULL?

No.

This sounds like your implementation does not support OpenGL(R) 3.2.

[QUOTE=Alfonse Reinheart;1264348]

  1. Is there a way to check and see WHY glfwCreateWindow returned NULL?
    No.[/QUOTE]
    We have the GLFW source code. Of course we can debug it and step into glfwCreateWindow. But I don’t think that will be very helpful.
    But it is definitely possible to debug it and find out where exactly an error occours, causing the function to return NULL.