java - How to display text in LWJGL using version 3.2 or above -


i've been using lwjgl wiki learn how use library, , i've been setting lwjgl following (as per this tutorial):

pixelformat pixelformat = new pixelformat(); contextattribs contextattributes = new contextattribs(3, 2)                                        .withforwardcompatible(true)                                        .withprofilecore(true); display.settitle("title"); try {     display.setfullscreen(true);     display.setvsyncenabled(true);     display.create(pixelformat, contextattributes); } catch(lwjglexception e) {     e.printstacktrace(); }  glviewport(0, 0, sizex, sizey); glclearcolor(0, 0, 0, 1); 

another tutorial explains how draw text. however, truetypefont deprecated replaced standard unicodefont. initialize , use this:

unicodefont font = null; try {     font = new unicodefont(font.createfont(font.truetype_font,                               new file("path/to/font.ttf")).derivefont(24))); } catch (fontformatexception | ioexception e) {     e.printstacktrace(); }  while(true) {     glclear(gl_color_buffer_bit);     font.drawstring(50.0f, 50.0f, "hi there.",                            new color(1.0f, 1.0f, 1.0f, 1.0f)); } 

this generates following error:

exception in thread "main" java.lang.illegalstateexception: function not supported @ org.lwjgl.bufferchecks.checkfunctionaddress(bufferchecks.java:58) @ org.lwjgl.opengl.gl11.glcolor4f(gl11.java:881) @ org.newdawn.slick.opengl.renderer.immediatemodeoglrenderer.glcolor4f(immediatemodeoglrenderer.java:119) @ org.newdawn.slick.color.bind(color.java:180) @ org.newdawn.slick.truetypefont.drawstring(truetypefont.java:367) @ org.newdawn.slick.truetypefont.drawstring(truetypefont.java:359) 

at line drawstring called. how fix this?

you're creating opengl 3.2 forward compatible context, apparently font renderer using immediate mode rendering, removed version of opengl. either create compatibility context or switch other method of rendering fonts.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -