I have looked around and read a lot about static functions and variables, I have understood that one can not simply call a non-static variable/function in an static function and so on, so my question is how can I solve this problem I'm having with GLFW key_callback.
In GLFW we have this:
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
and we add this like other window related calls:
glfwMakeContextCurrent(window);
glfwSetKeyCallback(window, window_key_callback);
But now I want to be able to call another class function if 'space' key is pressed in the key_callback like this:
in .h file I have
#include "A.h"
...
private:
A *anotherClass;
and in .cpp file I have in the constructor
anotherClass = new A();
and the rest
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
antoherClass->draw();
}
and this anotherClass is not static, I just want to start drawing if space is pressed.
Can someone help me with this?