2013-02-27 67 views
4

我一直在使用lwjgl一段时间,最近我决定从固定功能管线切换到着色器。所以,当我开始我的程序时,我首先设置了ContextAttrib(3,2),所以我将使用GL 3.2+。问题是,当我打开更高版本的GL时,很多函数变得不受支持。在切换到更高的GL之前,我使用了Slick的字体(TrueTypeFont)来呈现我需要的文本,但是现在TrueTypeFont的drawString方法在其本身中具有不受支持的功能。我试图谷歌解决方案,但没有出现。LWJGL 3.2.0+字体

有谁知道是否可以用slick-util库来渲染文本,而使用GL版本3.2+或与其他库?或该主题上的任何链接。我将不胜感激任何帮助或建议。

编辑:用于启动的openGL 3.2和较新的形式教程维基

try 
    { 
     PixelFormat pixelFormat = new PixelFormat(); 
     ContextAttribs contextAtrributes = new ContextAttribs(3, 2) 
      .withForwardCompatible(true) 
      .withProfileCore(true); 

     Display.create(pixelFormat, contextAtrributes); 
    } catch (LWJGLException e){ 
     e.printStackTrace(); 
     return; 
    } 

代码通过用openGL 3.2或更新你被迫只能使用着色器。呼吁UnicodeFont或TrueTypeFont,或像GL11.glMatrixMode(GL11.GL_PROJECTION)任何其他固定管线功能时drawString之出现异常;:

Exception in thread "Thread-0" java.lang.IllegalStateException: Function is not supported 
at org.lwjgl.BufferChecks.checkFunctionAddress(BufferChecks.java:58) 
at org.lwjgl.opengl.GL11.glColor4f(GL11.java:881) 
at org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer.glColor4f(ImmediateModeOGLRenderer.java:127) 
at org.newdawn.slick.Color.bind(Color.java:182) 
at org.newdawn.slick.UnicodeFont.drawDisplayList(UnicodeFont.java:443) 
at org.newdawn.slick.UnicodeFont.drawString(UnicodeFont.java:551) 
at org.newdawn.slick.UnicodeFont.drawString(UnicodeFont.java:559) 
at org.newdawn.slick.UnicodeFont.drawString(UnicodeFont.java:555) 
at application.Controller.render3D(Controller.java:163) 
at Engine.Engine.renderScene3D(Engine.java:230) 
at Engine.Engine.render(Engine.java:334) 
at Engine.Engine.gameLoop(Engine.java:306) 
at Engine.Engine.access$1(Engine.java:246) 
at Engine.Engine$1.run(Engine.java:154) 

感谢。

+0

我看到这个问题是比较老的已经,你有没有找到一个解决办法? – skiwi 2014-02-06 17:24:02

回答

0

在GameDevSE弹出,以及您可能需要为一探究竟here

列举了类似的问题:

这听起来像你可能没有actually request an appropriately-versioned OpenGL context(即,一个3.2支持)。要做到这一点,你必须提供上下文属性请求所需的版本,当你调用Display.create()

PixelFormat pixelFormat = new PixelFormat(); 
ContextAttribs contextAtrributes = new ContextAttribs(3, 2) 
    .withForwardCompatible(true) 
    .withProfileCore(true); 

try { 
     Display.setDisplayMode(new DisplayMode(320, 240)); 
     Display.setTitle("Version selection"); 
     Display.create(pixelFormat, contextAtrributes); 
} catch (LWJGLException e) { 
    e.printStackTrace(); 
    System.exit(-1); 
}