0
我正在使用LWJGL向渲染緩衝區的屏幕外幀緩衝區渲染三角形。渲染場景後,我使用glReadPixels
將渲染緩衝區中的數據讀出到RAM中。前幾幀很好,但程序崩潰了(SEGFAULT,或SIGABRT,...)。幾幀後,LWJGL在glReadPixels上崩潰
我在這裏做錯了什麼?
//Create memory buffer in RAM to copy frame from GPU to.
ByteBuffer buf = BufferUtils.createByteBuffer(3*width*height);
while(true){
// Set framebuffer, clear screen, render objects, wait for render to finish, ...
...
//Read frame from GPU to RAM
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, buf);
//Move cursor in buffer back to the begin and copy the contents to the java image
buf.position(0);
buf.get(imgBackingByteArray);
//Use buffer
...
}