Hello Guest

GLFW Callbacks

  • 4 Replies
  • 8216 Views
GLFW Callbacks
« on: November 28, 2019, 20:51:18 »
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.

*

Offline KaiHH

  • ****
  • 334
Re: GLFW Callbacks
« Reply #1 on: November 28, 2019, 21:33:28 »
The Get Started page on lwjgl.org contains an example with a GLFW callback (keycallback).

Re: GLFW Callbacks
« Reply #2 on: November 29, 2019, 02:02:47 »
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?

*

Offline KaiHH

  • ****
  • 334
Re: GLFW Callbacks
« Reply #3 on: November 29, 2019, 07:51:17 »
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.

Re: GLFW Callbacks
« Reply #4 on: November 29, 2019, 11:37:33 »
Thank you.