From dbc260bd2e917ee9001461749c99da0c9cbfaf9a Mon Sep 17 00:00:00 2001
From: Sven Gothel
+ * If MSAA is being used and no sampling sink is attached via {@link #setSamplingSink(FBObject)} + * a new sampling sink is being created. + *
+ ** Automatically called by {@link #reset(GL, int, int, int, boolean)} * and {@link #syncSamplingSink(GL)}. *
@@ -1953,18 +1954,19 @@ public class FBObject { * @throws GLException in case of an error, i.e. size too big, etc .. */ public final void resetSamplingSink(GL gl) throws GLException { - if(null == samplesSink ) { - return; // this is the sample sink! - } if(0 == samples) { // MSAA off - if(samplesSink.initialized) { + if(null != samplesSink && samplesSink.initialized) { // cleanup samplesSink.detachAll(gl); } return; } + if(null == samplesSink ) { + samplesSink = new FBObject(); + } + if(!samplesSink.initialized) { samplesSink.init(gl, width, height, 0); } @@ -2026,6 +2028,27 @@ public class FBObject { } } + /** + * Setting this FBO sampling sink. + * @param newSamplingSink the new FBO sampling sink to use, or null to remove current sampling sink + * @throws GLException if this FBO doesn't use MSAA or the given sink uses MSAA itself + */ + public void setSamplingSink(FBObject newSamplingSink) throws GLException { + if( null == newSamplingSink) { + samplesSink = null; + samplesSinkTexture = null; + } else if( samples > 0 ) { + if( newSamplingSink.getNumSamples() > 0 ) { + throw new GLException("SamplingSink FBO cannot use MSAA itself: "+newSamplingSink); + } + samplesSink = newSamplingSink; + samplesSinkTexture = (TextureAttachment) newSamplingSink.getColorbuffer(0); + } else { + throw new GLException("Setting SamplingSink for non MSAA FBO not allowed: "+this); + } + samplesSinkDirty = true; + } + /** * Bind this FBO, i.e. bind write framebuffer to {@link #getWriteFramebuffer()}. * @@ -2279,7 +2302,7 @@ public class FBObject { return "FBO[name r/w "+fbName+"/"+getReadFramebuffer()+", init "+initialized+", bound "+bound+", size "+width+"x"+height+ ", samples "+samples+"/"+maxSamples+", depth "+depth+", stencil "+stencil+ ", color attachments: "+colorAttachmentCount+"/"+maxColorAttachments+ - ": "+caps+", msaa-sink "+samplesSinkTexture+", isSamplesSink "+(null == samplesSink)+ + ": "+caps+", msaa-sink "+samplesSinkTexture+", hasSamplesSink "+(null != samplesSink)+ ", state "+getStatusString()+", obj "+toHexString(objectHashCode())+"]"; } -- cgit v1.2.3