GLFW C++ Class

nobody wrote on Friday, April 14, 2006:

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 wrote on Friday, April 14, 2006:

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

nobody wrote on Friday, April 14, 2006:

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.

elmindreda wrote on Friday, April 14, 2006:

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.