Results 1 to 3 of 3

Thread: NULL returned from glfwCreateWindow when setting OpenGL context hints

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2015
    Posts
    5

    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:


    Code :
    printf("Setting up window hints.\n");
            glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing
    printf("Set AA.\n");
            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.\n");
            glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    printf("Set minor version.\n");
            glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // To make MacOS happy; should not be needed
    //printf("Set COMPAT hint.\n");
            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.\n", 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.\n"); 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
    Attached Files Attached Files

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,675
    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

    2) Is there a way to check and see WHY glfwCreateWindow returned NULL?
    No.

  3. #3
    Senior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    281
    This sounds like your implementation does not support OpenGL(R) 3.2.

    Quote Originally Posted by Alfonse Reinheart View Post
    2) Is there a way to check and see WHY glfwCreateWindow returned NULL?
    No.
    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.

Similar Threads

  1. Replies: 4
    Last Post: 10-02-2014, 08:11 PM
  2. Problem setting up Opengl Context in Windows
    By DeeMan in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-27-2011, 01:34 PM
  3. Setting up an OpenGL context
    By in forum OpenGL: Linux
    Replies: 1
    Last Post: 10-14-2004, 01:51 AM
  4. Rendering context on windows 2000 NULL.........
    By catchshailu in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 04-04-2003, 05:20 AM
  5. Replies: 1
    Last Post: 09-01-2001, 10:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean