I'm trying to make a callback to a non static C++ member function in a class I made. The callback function is not designed by me. Only solutions I saw online were to make the function and related variable static but that does not go well with OpenGL and it's other functions.
Are there any other options that I can try to make this callback work.
What is the callback function? I presume you are talking about the GLUT library's glutReshapeFunc callback?
GLUT is a very old library, and it was not designed to work with C++. A general solution is probably overkill; it is probably simplest to just write something that directly accesses your object:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
OpenGL* myopengl;
void MyReshapeFunc( int width, int height )
{
myopengl->changeSize( width, height );
}
int main(...)
{
...
myopengl = &whatever_your_OpenGL_object_is_called;
glutReshapeFunc( &MyReshapeFunc );
...
}