Fixes some problems with framebuffers (second attempt)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9937 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
jul..om 12 years ago
parent 89608f3fd5
commit 0170c7b5eb
  1. 27
      engine/src/jogl/com/jme3/renderer/jogl/JoglRenderer.java

@ -407,10 +407,10 @@ public class JoglRenderer implements Renderer {
lastFb = null; lastFb = null;
GL gl = GLContext.getCurrentGL(); GL gl = GLContext.getCurrentGL();
gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, intBuf16); gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, intBuf1);
initialDrawBuf = intBuf16.get(0); initialDrawBuf = intBuf1.get(0);
gl.glGetIntegerv(GL2.GL_READ_BUFFER, intBuf16); gl.glGetIntegerv(GL2.GL_READ_BUFFER, intBuf1);
initialReadBuf = intBuf16.get(0); initialReadBuf = intBuf1.get(0);
} }
public void resetGLObjects() { public void resetGLObjects() {
@ -1687,11 +1687,24 @@ public class JoglRenderer implements Renderer {
} }
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) { public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
GL gl = GLContext.getCurrentGL();
if (fb != null) { if (fb != null) {
return; RenderBuffer rb = fb.getColorBuffer();
if (rb == null) {
throw new IllegalArgumentException("Specified framebuffer"
+ " does not have a colorbuffer");
}
setFrameBuffer(fb);
if (context.boundReadBuf != rb.getSlot()) {
gl.getGL2().glReadBuffer(GL.GL_COLOR_ATTACHMENT0 + rb.getSlot());
context.boundReadBuf = rb.getSlot();
}
} else {
setFrameBuffer(null);
} }
GL gl = GLContext.getCurrentGL();
gl.glReadPixels(vpX, vpY, vpW, vpH, GL2GL3.GL_BGRA, GL.GL_UNSIGNED_BYTE, byteBuf); gl.glReadPixels(vpX, vpY, vpW, vpH, /*GL.GL_RGBA*/ GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, byteBuf);
} }
private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) { private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) {

Loading…
Cancel
Save