LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Maetschl on April 18, 2016, 02:17:20

Title: I can't display text on screen. (with font)
Post by: Maetschl on April 18, 2016, 02:17:20
Sorry guys, i hate to ask this but can not find much documentation or example of this.

I making game and need develop de HUD, render some text with some font format (TTF file for example).

But i can not find an not deprecated example  :'(

I hope someone can help me.

Stackoverflow question: http://stackoverflow.com/questions/36684285/render-text-with-lwjgl-and-ttf-file

Sorry if it is a duplicated question, but I found the solution.

Thanx!

Attached a actual photo of my game =)

Regards!
Title: Re: I can't display text on screen. (with font)
Post by: spasi on April 18, 2016, 06:58:43
See the Truetype demos here (https://github.com/LWJGL/lwjgl3/tree/master/modules/core/src/test/java/org/lwjgl/demo/stb). They demonstrate TTF rendering using stb_truetype from the stb (https://github.com/nothings/stb) library.
Title: Re: I can't display text on screen. (with font)
Post by: Maetschl on April 18, 2016, 15:33:13
I tried but I have this error at compile  :-\

Exception in thread "main" java.lang.NoSuchMethodError: org.lwjgl.system.MemoryUtil.memUTF8(Ljava/nio/ByteBuffer;)Ljava/lang/String;
at org.lwjgl.demo.stb.FontDemo.<init>(FontDemo.java:59)
at org.lwjgl.demo.stb.Truetype.<init>(Truetype.java:26)
at org.lwjgl.demo.stb.Truetype.main(Truetype.java:37)


And this errors on code:

Line 42: STBTTBakedChar.Buffer cdata = STBTTBakedChar.malloc(96); // Maybe can change it for mallocBuffer(int)?
Line 106: STBTTAlignedQuad q = STBTTAlignedQuad.mallocStack(stack);  // ??
Title: Re: I can't display text on screen. (with font)
Post by: spasi on April 18, 2016, 16:26:33
Demos in the LWJGL repository require the latest nightly build (https://www.lwjgl.org/download) to compile and run.
Title: Re: I can't display text on screen. (with font)
Post by: Maetschl on April 18, 2016, 16:52:50
 :o :o :o :o :o :o

it's works!

Thanks!!

:-[