Java 调用Texture.update时出现nullPointerException

Java 调用Texture.update时出现nullPointerException,java,opengl,jogl,Java,Opengl,Jogl,当尝试更新纹理时,我得到一个nullPointerException。我的代码是 t.updateImage(gl, new TextureData(Client.profile, GL.GL_TEXTURE_2D, camWidth, camHeight, 0, GL.GL_RGB, GL.GL_UNSIGNED_INT,

当尝试更新纹理时,我得到一个nullPointerException。我的代码是

    t.updateImage(gl, new TextureData(Client.profile,
            GL.GL_TEXTURE_2D,
            camWidth,
            camHeight,
            0,
            GL.GL_RGB,
            GL.GL_UNSIGNED_INT,
            false,
            false,
            false,
            testBuf(),
            null
            ));
testBuf为:

    public IntBuffer testBuf(){

    int[] ints = new int[bufWidth*bufHeight];

    for(int i = 0; i < bufWidth*bufHeight; i++){
        ints[i] = 155;
    }

    IntBuffer intBuf = IntBuffer.wrap(ints);

    return intBuf;
}
之前,eclipse没有显示任何错误,但是当我运行程序时,它会在带有t.updateImage的行上抛出一个NullPointerException。。。 也许值得注意的是,我正在从display方法调用这个方法,即使它在init方法中也不起作用


我错过了什么?我创建缓冲区的方式有问题吗?

尝试在变量中获取testbuf return,并检查其null是否有问题,它是否通过了!=null语句,并打印为java.nio.HeapIntBuffer[pos=0 lim=307200 cap=307200]请发布完整的堆栈跟踪和SSCCE:您应该使用com.jogamp.common.nio.Buffers为JOGL创建缓冲区。检查t或gl是否为null。事实证明,问题是t为null,因为我在init方法中出错了。谢谢