glGetTexImage访问违规

时间:2016-02-28 03:47:08

标签: java opengl textures lwjgl framebuffer

当我在glGetTexImage()的纹理上调用Framebuffer时,出现此错误:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffabf967a2b, pid=1816, tid=14712

这是我的代码:

MagicaAdventura.GAME.gameBuffer.bindTexture();
glGetTexImage(GL_TEXTURE_2D, 0, GL12.GL_BGR, GL_UNSIGNED_BYTE, buf);//line that causes the error

以下是绑定方法的代码:

public void bind(int texture) {
    if(currentBound[texture] != resource.getID() || lastBoundInFramebuffer != Renderer.CURRENT_FRAMEBUFFER) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0 + texture);
        lastBoundInFramebuffer = Renderer.CURRENT_FRAMEBUFFER;
        currentBound[texture] = resource.getID();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, resource.getID());
    }
}

纹理绑定代码适用于其他事情。

1 个答案:

答案 0 :(得分:0)

缓冲区没有为填充纹理分配空间为2的幂,所以我切换到使用glReadPixels