LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: xsupermetroidx on December 23, 2014, 18:09:06

Title: LWJGL 3.0 - GLFWErrorCallback usage
Post by: xsupermetroidx 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?
Title: Re: LWJGL 3.0 - GLFWErrorCallback usage
Post by: spasi 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.
Title: Re: LWJGL 3.0 - GLFWErrorCallback usage
Post by: xsupermetroidx on December 24, 2014, 01:31:22
Thanks for the swift reply... got it figured out now.
Title: Re: LWJGL 3.0 - GLFWErrorCallback usage
Post by: SHC on December 24, 2014, 09:46:11
Shouldn't I use MemoryUtil.memDecodeUTF8(description); for that Spasi?
Title: Re: LWJGL 3.0 - GLFWErrorCallback usage
Post by: spasi 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.
Title: Re: LWJGL 3.0 - GLFWErrorCallback usage
Post by: SHC 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.