JOGL-创建纹理无效

时间:2013-11-13 01:18:18

标签: java jogl

任何人都可以告诉我为什么我在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

0 个答案:

没有答案