我使用 lwjgl 一段时间了,最近我决定从固定功能管道切换到着色器。因此,当我启动程序时,我首先设置 ContextAttrib(3, 2),这样我将使用 GL 3.2+。问题是,当我打开更高版本的 GL 时,很多功能都不受支持。在切换到更高的GL之前,我已经使用Slick的字体(TrueTypeFont)来渲染我需要的文本,但是现在TrueTypeFont的drawString方法本身有一个不受支持的功能。我尝试用谷歌搜索解决方案,但没有任何结果。
有谁知道在使用 GL 版本 3.2+ 或其他库时是否可以使用 slick-util 库渲染文本?或有关该主题的任何链接。我将不胜感激任何帮助或建议。
编辑:启动 openGL 3.2 及更新版本的代码来自 wiki 上的教程
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 上调用 drawString 或任何其他固定函数管道函数(如 GL11.glMatrixMode(GL11.GL_PROJECTION);)时出现的异常:
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)
thanks.
GameDevSE 上也出现了类似的问题,您可能需要检查一下here https://gamedev.stackexchange.com/questions/71578/why-do-i-get-function-not-supported-exceptions-for-opengl-3-2-functions-using
Citing:
听起来你可能没有实际上请求一个适当版本的 OpenGL 上下文 http://lwjgl.org/wiki/index.php?title=Version_selection(即支持 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);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)