Possible bug in STBTTFontInfo

Started by asyx, September 18, 2015, 15:07:12

Previous topic - Next topic

asyx

Hello!

I played around with the TrueType STB bindings a little and tried to port a C example that renders text into a PNG.

So, that works now but I think there's a bug in the STBTTFontInfo.malloc() method.

http://pastebin.com/ZbVC7k4L

Here's my code (working). If you uncomment line 72 and comment line 73, it crashes with

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.lwjgl.stb.STBTTFontinfo.offsets()I


on line 72.

At first I thought that it might be a problem with my library path but I then just got the size of the struct via C and created the buffer manually and that works flawlessly.

I'm using the LWJGL version from the snapshot maven repository.

Kai

You are likely using an old DLL/shared library of LWJGL. This native function is available in the latest 3.0.0a release and the latest 3.0.0b nightly. In Maven it comes with the `org.lwjgl:lwjgl-natives-<os>` artifact.
Check your -Djava.library.path.

asyx

Cleaned it and repackaged it. Everything but this method works. And the library path works as well. Otherwise, I couldn't use all the other STB stuff I'm using.

Kai

Quote from: asyx on September 18, 2015, 15:39:51
Otherwise, I couldn't use all the other STB stuff I'm using.
Not necessarily. Could have been that the native interface of the structs changed with one build version which added that "offset" function.
My theory is that you are linking against an old version of the LWJGL3 native/shared library. ;)

asyx

But wouldn't maven do that for me? Like, I unpacked the native libraries from the jar that I got together with the lwjgl.jar. I mean, maven should prevent f*ckups like that, right?

spasi

Thanks asyx, this is a bug in LWJGL. It happens because STBTTFontInfo.malloc() is the first native LWJGL method you call and the library is not properly initialized (because this particular struct is opaque = has no public fields). It will be fixed in the next nightly build.

In the meantime, a workaround is to call LWJGLUtil.initialize() before STBTTFontInfo.malloc().

spasi

This should be fixed in the latest nightly build (3.0.0b #28).

FortressBuilder

@spasi 3.0.0b build 28 does not include the glfw natives, leading to errors during initialization.

spasi