GLFW C++ Class

Using GLFW
  • Nobody/Anonymous

    I'm using GLFW to write a simple OpenGL game for a class project that I'm working on. I finally managed to seperate GLFW and my OpenGL code into seperate C++ classes without anything breaking. (for modularity reasons, that's the point of this class project)

    What I've run into now is the setWindowResizeCallback() and setWindowRefreshCallback() functions.

    I need to know if it's possible to define

    void GLFWCALL resize(int newWidth,int newHeight);
    void GLFWCALL refresh();

    inside the class so they can use the pointer the class has to the graphics module to tell OpenGL what it needs to do. This is the last OpenGL code in my GLFW module.

    I'm not sure what GLFWCALL is here, but when I try doing

    void GLFWCALL GLFWrapper::refresh()

    I get this error:

    "void (GLFWrap::)() does not match void(*)()"

    I tried making them friend functions outside of the class, but then I need some way to pass the correct instance of the object to them and I don't think that's possible.

    Any help would be appreciated.


    • Nobody/Anonymous

      Ok, maybe I was wrong. I tried making the functions static, but now they can't access the non-static pointer to the graphics module.

      I suppose I could make that static, but I'm not sure if that's a good idea or not.

      Back to the books I guess.

      • Camilla Löwy

        Camilla Löwy - 2006-04-14

        Make a static pointer to the instance of your class, and work through that. GLFW unfortunately doesn't currently have a way to store a user pointer, but a future version might, in order to make life easier for the C++ programmer.

    • Nobody/Anonymous

      I see this issue is already addressed in a few other threads.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks