A
A
Alexander Shpak2014-12-13 20:26:53
C++ / C#
Alexander Shpak, 2014-12-13 20:26:53

How to throw a pointer to glfwSetKeyCallback in C?

Out of curiosity, I'm trying GLFW, and for processing the keyboard there is a function in it
glfwSetKeyCallback(window, key_callback);
and, accordingly, the callback function key_callback is written to process clicks. But it is not clear to me how to pass my data to this function, for example, a pointer to some data.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
EndUser, 2014-12-14
@EndUser

I didn't try GLFW, but do I understand correctly that the function signature allows you to send 4 integers?
Nor is any integer intended for a pointer or reference type.
Philosophically speaking, we can say that the parameters for the callback are formed by the caller, not you.
If you try to hack philosophy ugly, you can try to use a global variable ugly.

H
Hertz, 2015-01-12
@Hertz

Look at glfwSetWindowUserPointer, glfwGetWindowUserPointer.
Designed for this, a pointer to GLFWwindow is passed to you in the callback.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question