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).
This commit is contained in:
Nehon 2014-12-28 16:18:54 +01:00
parent 995ab83a9e
commit 9f459af4e3
6 changed files with 39 additions and 2 deletions

View File

@ -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");
}
}

View File

@ -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
*/

View File

@ -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) {

View File

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

View File

@ -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");
}
}

View File

@ -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");
}
}