2016-02-28 177 views
-1

當我打電話glGetTexImage()從一個Framebuffer紋理,我得到這個錯誤:glGetTexImage訪問衝突

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

您是否分配足夠大的'buf'來容納圖像數據? –

+0

我忘了給padding分配兩個寬度的空間。 – minecraftwarlock

回答

0

緩衝區沒有分配空間來填充紋理的2次方,所以我切換到使用glReadPixels