GLFW Callbacks

Started by trBlueJ, November 28, 2019, 20:51:18

Previous topic - Next topic

trBlueJ

Can someone please help me with callbacks in GLFW, they don't work as described on the GLFW website as it is in C and the starting up does not include how to define a function as the callback.

KaiHH

The Get Started page on lwjgl.org contains an example with a GLFW callback (keycallback).

trBlueJ

Quote from: KaiHH on November 28, 2019, 21:33:28
The Get Started page on lwjgl.org contains an example with a GLFW callback (keycallback).

Yes, however, I was wondering if there was a way to directly reference a function instead?

KaiHH

Depends on what exactly you mean by "function" since in Java there is no such thing as a function. If you mean a "method" and by that you mean passing a reference to a Java method to a GLFW method expecting a callback interface type as a parameter, then you can simply use a Java Method Reference (since Java 8).
This is a standard feature in Java 8 and applies to all interface-typed receivers, such as method parameters or local methods variables.

trBlueJ