GLFW initialized, yet not?

Using GLFW
mSkull
2013-06-27
2013-06-27
  • mSkull
    mSkull
    2013-06-27

    I'm having this weird issue where the glfwCreateWindow function fails, complaining about how I havn't initialized GLFW, even though the glfwInit function returns successful just before?

    I'm guessing the reason for this might be because I havn't setup GLFW completely correctly, but if so I'm gonna need some help getting that fixed, as I'm not to experienced in setting up external libraries, especially in Code::Blocks.

    Here's is an outtake from my Base class's Init function, which is where I'm getting the error

    bool Base::Init()
    {
        glfwSetErrorCallback( error_callback );
    
        if( !glfwInit() ) // <-- this function returns true, yet sends an error to the error_callback function
        {
            cout << "Failed to initialize GLFW!" << endl;
            return false;
        }
    
        // Here is my main issue. GLFW sends the same error to the call_back function again
        window = glfwCreateWindow( 800, 600, "GLFW Window", glfwGetPrimaryMonitor(), NULL )
    
        if( !window )
        {
            cout << "Failed to create window!" << endl;
            return false;
        }
    
        glfwMakeContextCurrent( window );
    
        ...
    
        return true;
    }
    

    Here's the error messages from the console

    65537 The GLFW library is not initialized
    65537 The GLFW library is not initialized
    Failed to create window!

    Thanks in advance for any help you can give me

    mSkull

     
  • Cameron King
    Cameron King
    2013-06-27

    Have you tried placing the glfwSetErrorCallback( error_callback ); after the glfwInit();?

     
  • mSkull
    mSkull
    2013-06-27

    According to the documentation the glfwSetErrorCallback is one of the functions that may be called before glfwInit. Initially I didn't have that function at all, and added it after the window failed to create.

    I can try to do what you say, but I doubt it'll change anything

    edit:
    I tried changing the order, but got the same result
    Interesting enough, I still got 2 of the 65537 error - I thought one of them came from glfwInit, but apparently not

    In any case, thanks fro your reply

     
    Last edit: mSkull 2013-06-27