Search code examples
javaopengltextureslwjglframebuffer

glGetTexImage ACCESS VIOLATION


When I call glGetTexImage() on a texture from a Framebuffer, I get this error:

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

Here is my code:

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

And here is the code for the bind method:

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());
    }
}

The texture binding code works fine for other things.


Solution

  • The buffer wasn't allocating space for the padding the texture to a power of 2 so I switched to using glReadPixels.