One can now call readFrameBuffer with a specific format, implementation has been done for the GLRenderer only.

For now only placeholders have been done for the renderers that are still not using URA (all except LWJGL).
experimental
Nehon 10 years ago
parent 995ab83a9e
commit 9f459af4e3
  1. 4
      jme3-android/src/main/java/com/jme3/renderer/android/OGLESShaderRenderer.java
  2. 15
      jme3-core/src/main/java/com/jme3/renderer/Renderer.java
  3. 11
      jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
  4. 3
      jme3-core/src/main/java/com/jme3/system/NullRenderer.java
  5. 4
      jme3-ios/src/main/java/com/jme3/renderer/ios/IGLESShaderRenderer.java
  6. 4
      jme3-jogl/src/main/java/com/jme3/renderer/jogl/JoglRenderer.java

@ -2564,4 +2564,8 @@ public class OGLESShaderRenderer implements Renderer {
public void setLinearizeSrgbImages(boolean linearize) {
//TODO once opglES3.0 is supported maybe....
}
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly");
}
}

@ -222,7 +222,7 @@ public interface Renderer {
/**
* Reads the pixels currently stored in the specified framebuffer
* into the given ByteBuffer object.
* Only color pixels are transferred, the format is BGRA with 8 bits
* Only color pixels are transferred, the format is RGBA with 8 bits
* per component. The given byte buffer should have at least
* fb.getWidth() * fb.getHeight() * 4 bytes remaining.
*
@ -231,6 +231,19 @@ public interface Renderer {
*/
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf);
/**
* Reads the pixels currently stored in the specified framebuffer
* into the given ByteBuffer object.
* Only color pixels are transferred, witht hte given format.
* The given byte buffer should have at least
* fb.getWidth() * fb.getHeight() * 4 bytes remaining.
*
* @param fb The framebuffer to read from
* @param byteBuf The bytebuffer to transfer color data to
* @param format the image format to use when reading the frameBuffer.
*/
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format);
/**
* Deletes a framebuffer and all attached renderbuffers
*/

@ -1629,6 +1629,10 @@ public class GLRenderer implements Renderer {
}
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) {
readFrameBufferWithGLFormat(fb, byteBuf, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE);
}
private void readFrameBufferWithGLFormat(FrameBuffer fb, ByteBuffer byteBuf, int glFormat, int dataType) {
if (fb != null) {
RenderBuffer rb = fb.getColorBuffer();
if (rb == null) {
@ -1647,7 +1651,12 @@ public class GLRenderer implements Renderer {
setFrameBuffer(null);
}
gl.glReadPixels(vpX, vpY, vpW, vpH, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, byteBuf);
gl.glReadPixels(vpX, vpY, vpW, vpH, glFormat, dataType, byteBuf);
}
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
GLImageFormat glFormat = texUtil.getImageFormatWithError(format, false);
readFrameBufferWithGLFormat(fb, byteBuf, glFormat.format, glFormat.dataType);
}
private void deleteRenderBuffer(FrameBuffer fb, RenderBuffer rb) {

@ -161,4 +161,7 @@ public class NullRenderer implements Renderer {
public void setLinearizeSrgbImages(boolean linearize) {
}
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
}
}

@ -2593,4 +2593,8 @@ public class IGLESShaderRenderer implements Renderer {
public void setLinearizeSrgbImages(boolean linearize) {
}
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly");
}
}

@ -2713,4 +2713,8 @@ public class JoglRenderer implements Renderer {
public void setLinearizeSrgbImages(boolean linearize) {
linearizeSrgbImages = linearize;
}
public void readFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) {
throw new UnsupportedOperationException("Not supported yet. URA will make that work seamlessly");
}
}

Loading…
Cancel
Save