I'm currently learning OpenGL in C++.
I'm trying to read the keyboard inputs by setting glfwSetKeyCallback(this->window, ctrl->key_callback);
Where this->window
is my GLFWwindow* window
and ctrl->key_callback
is a method of my custom object Controller
.
I'm getting a compiler error with MSVC:
non-standard syntax; use '&' to create a pointer to member
How can I indicate the key_callback
method trough that Controller* ctrl
pointer?
Where the error pops out:
void Class1::set_callback(Controller* ctrl)
{
glfwSetKeyCallback(this->window, ctrl->key_callback);
}
Controller.h
#include "Class1.h"
#include "GLFW/glfw3.h"
class Controller
{
public:
Controller(Class1* c);
~Controller();
void key_callback(GLFWwindow* glwindow, int key, int scancode, int action, int mods);
private:
Window* window;
};
I'm calling set_callback in main.cpp
#include "Class1.h"
#include "Controller.h"
int main()
{
Class1* my_class = new Class1();
Controller* controller = new Controller(my_class);
my_class->set_callback(controller);
return 0;
}
Please let me know if I didn't formulate my question/title right, I'm pretty confused with this syntax