谁能告诉我为什么我在 JOGL 中遇到这个错误以及如何解决这个问题?我之前启用了纹理,但仅此一次失败。我尝试清除缓冲区但 nada。
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Create texture ID invalid: texID 0, glerr 0x0
at com.jogamp.opengl.util.texture.Texture.validateTexID(Texture.java:1090)
at com.jogamp.opengl.util.texture.Texture.updateImage(Texture.java:457)
at com.jogamp.opengl.util.texture.Texture.updateImage(Texture.java:434)
at com.jogamp.opengl.util.texture.Texture.<init>(Texture.java:203)
at com.jogamp.opengl.util.texture.TextureIO.newTexture(TextureIO.java:448)
at com.jogamp.opengl.util.texture.TextureIO.newTexture(TextureIO.java:499)
at Object1.createTexture1(Object1.java:42)
我正在尝试使用以下代码片段创建纹理以映射到扫描对象:
Texture createTexture(String fname)
{
try {
InputStream stream = getClass().getResourceAsStream(fname);
myTexture = TextureIO.newTexture( stream, true, "jpg" ); //creates a texture
} catch (IOException exc) {
exc.printStackTrace();
System.exit(1);
}
myTexture.setTexParameteri(JOGL.gl, GL2.GL_TEXTURE_MAG_FILTER,
GL2.GL_LINEAR); //sets properties for the texture
return myTexture;
}
I have designed my redraw as:
JOGL.gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
myTexture = createTexture("Sunrise.jpg");
myTexture.enable(JOGL.gl);
myTexture.bind(JOGL.gl);
JOGL.gl.glBegin(GL2.GL_QUADS);// followed by drawing a quad and mapping the texture to it