Hello Guest

LWJGL 3.0 - GLFWErrorCallback usage

  • 5 Replies
  • 3390 Views
LWJGL 3.0 - GLFWErrorCallback usage
« on: December 23, 2014, 18:09:06 »
This is a simple question about how to properly use GLFW's error callbacks. The error event callback has the signature "int error, long description", where description is supposed to be a pointer to a char array according to GLFW's documentation. How can I access the error description string, or is this an oversight/impossibility at the moment?

*

Offline spasi

  • *****
  • 2163
    • WebHotelier
Re: LWJGL 3.0 - GLFWErrorCallback usage
« Reply #1 on: December 23, 2014, 18:54:07 »
See the org.lwjgl.glfw.Callbacks class. There is a method errorCallbackDescriptionString, which converts the description pointer value to a Java String. There also two GLFWErrorCallback implementations (errorCallbackPrint & errorCallbackThrow).

If you're interested in seeing how this is implemented, see the memDecode* methods in the org.lwjgl.system.MemoryUtil class.

Re: LWJGL 3.0 - GLFWErrorCallback usage
« Reply #2 on: December 24, 2014, 01:31:22 »
Thanks for the swift reply... got it figured out now.

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: LWJGL 3.0 - GLFWErrorCallback usage
« Reply #3 on: December 24, 2014, 09:46:11 »
Shouldn't I use MemoryUtil.memDecodeUTF8(description); for that Spasi?

*

Offline spasi

  • *****
  • 2163
    • WebHotelier
Re: LWJGL 3.0 - GLFWErrorCallback usage
« Reply #4 on: December 24, 2014, 13:17:43 »
Yes, you can use memDecode* directly, but keep in mind that MemoryUtil is considered internal/unsafe API. The same is true for everything else in the org.lwjgl.system package. Technically, it is subject to change at any time, though I'm pretty sure that changes will be minimal if it ever comes to that.

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: LWJGL 3.0 - GLFWErrorCallback usage
« Reply #5 on: December 24, 2014, 13:27:56 »
Thanks for the clarification Spasi. I was already using memDecodeUTF8 in my code, so I was in doubt whether it was correct. I think I should better change it to Callbacks.errorCallbackDescriptionString() now.