2013-02-27 70 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); 
}