From 97cac351051f0dcb6d27060f7b781427c15750c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Wei=C3=9F?= Date: Fri, 16 Sep 2016 09:42:57 +0200 Subject: [PATCH] Fix for #502 --- .../java/com/jme3/texture/FrameBuffer.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java index a3f825d26..e5755c595 100644 --- a/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java +++ b/jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java @@ -363,6 +363,30 @@ public class FrameBuffer extends NativeObject { colorBufs.clear(); } + /** + * Add a color buffer without a texture bound to it. + * If MRT is enabled, then each subsequently added texture or buffer can be + * rendered to through a shader that writes to the array gl_FragData. + * If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) } + * is rendered to by the shader. + * + * @param format the format of the color buffer + * @see #addColorTexture(com.jme3.texture.Texture2D) + */ + public void addColorBuffer(Image.Format format){ + if (id != -1) + throw new UnsupportedOperationException("FrameBuffer already initialized."); + + if (format.isDepthFormat()) + throw new IllegalArgumentException("Color buffer format must be color/luminance."); + + RenderBuffer colorBuf = new RenderBuffer(); + colorBuf.slot = colorBufs.size(); + colorBuf.format = format; + + colorBufs.add(colorBuf); + } + /** * Add a color texture to use for this framebuffer. * If MRT is enabled, then each subsequently added texture can be @@ -371,6 +395,7 @@ public class FrameBuffer extends NativeObject { * is rendered to by the shader. * * @param tex The texture to add. + * @see #addColorBuffer(com.jme3.texture.Image.Format) */ public void addColorTexture(Texture2D tex) { if (id != -1)