From 711757aa4e087d97c3103489c47fbd7d76bcac3d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 20 Sep 2014 02:51:44 +0200 Subject: FBObject: Simplify API (init/reset); Only issue automatic resetSamplingSink(..) if required; Fix resetSamplingSink(..), isBound(), .. - Simplify API (init/reset) - use new unique methods for init and reset: - void init(final GL gl, final int newWidth, final int newHeight, final int newSamples) - does not issue resetSamplingSink(..) - boolean reset(final GL gl, final int newWidth, final int newHeight, final int newSamples) - always issues resetSamplingSink(..) - deprecated dual-use (init/reset): - boolean reset(final GL gl, final int newWidth, final int newHeight) - boolean reset(final GL gl, int newWidth, int newHeight, int newSamples, final boolean resetSamplingSink) - reset(..) no more creates a dummy 'samplingSink' instance if sampling > 0, left up to resetSamplingSink(..) - Track 'modified' state of FBObject, if size, format or any attachment has been changed since last - use(..) - syncSamplingSink(..) - resetSamplingSink(..) - Only issue resetSamplingSink(..) from syncSamplingSink(..)/use(..) if 'modified == true' +++ - Fix setSamplingSink(..), i.e. samplingSink state handling: - Validated whether given samplingSink is initialized, throws Exception if not. - Fix resetSamplingSink(..) - resets the bound state, i.e. leaves it untouched - also unbinds the samplingSink - sampleSinkDepthStencilMismatch() also returns true if this.depth/stencil == null, but samplingSink is not. - Newly created colorbuffer/-texture matches exiting colorbuffer's internal-format, if exists. - Using simplified resetSizeImpl(..) for size mismatch - Simplified samplingColorSink init check - Fix isBound() was: 'bound = bound && fbName != gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)' fix: 'bound = bound && fbName == gl.getBoundFramebuffer(GL.GL_FRAMEBUFFER)' - Fix detachRenderbuffer(..) validates whether detachment was successful, similar to detachColorbuffer(..) --- .../test/junit/jogl/acore/TestFBOMRTNEWT01.java | 4 +- .../junit/jogl/acore/TestFBOMix2DemosES2NEWT.java | 45 ++++++++++++++-------- .../test/junit/jogl/demos/es2/FBOMix2DemosES2.java | 10 ++--- .../demos/es2/TextureDraw02ES2ListenerFBO.java | 4 +- 4 files changed, 39 insertions(+), 24 deletions(-) (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java index 9e38b0d50..a66eddfdc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -167,7 +167,7 @@ public class TestFBOMRTNEWT01 extends UITestCase { // FBO w/ 2 texture2D color buffers final FBObject fbo_mrt = new FBObject(); - fbo_mrt.reset(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight()); + fbo_mrt.init(gl, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0); final TextureAttachment texA0 = fbo_mrt.attachTexture2D(gl, texA0Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); final TextureAttachment texA1; if(fbo_mrt.getMaxColorAttachments() > 1) { @@ -257,7 +257,7 @@ public class TestFBOMRTNEWT01 extends UITestCase { final int w = width/step * j; final int h = height/step * j; System.err.println("resize: "+step_i+" -> "+j+" - "+w+"x"+h); - fbo_mrt.reset(gl, w, h); + fbo_mrt.reset(gl, w, h, 0); winctx.window.setSize(w, h); step_i = j; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java index f8feefdcf..5eebf9cdd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java @@ -62,14 +62,14 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestFBOMix2DemosES2NEWT extends UITestCase { - static long duration = 500; // ms + static long duration = 1000; // ms static int swapInterval = 1; static boolean showFPS = false; static boolean forceES2 = false; static boolean doRotate = true; static boolean demo0Only = false; static int globalNumSamples = 0; - static boolean mainRun = false; + static boolean manual = false; @AfterClass public static void releaseClass() { @@ -81,7 +81,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); - if(mainRun) { + if(manual) { glWindow.setSize(512, 512); } else { glWindow.setSize(128, 128); @@ -100,7 +100,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { } public void dispose(final GLAutoDrawable drawable) {} public void display(final GLAutoDrawable drawable) { - if(mainRun) return; + if(manual) return; final int dw = drawable.getSurfaceWidth(); final int dh = drawable.getSurfaceHeight(); @@ -112,18 +112,24 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { snapshot(i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if( 3 == c ) { + demo.setMSAA(4); + } else if( 6 == c ) { new Thread() { @Override public void run() { - demo.setMSAA(4); + glWindow.setSize(dw+64, dh+64); } }.start(); - } else if( 6 == c ) { + } else if( 9 == c ) { + demo.setMSAA(8); + } else if( 12 == c ) { + demo.setMSAA(0); + } else if( 15 == c ) { new Thread() { @Override public void run() { - demo.setMSAA(8); + glWindow.setSize(dw+128, dh+128); } }.start(); - } else if(9 == c) { + } else if( 18 == c ) { c=0; new Thread() { @Override @@ -203,8 +209,8 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { } @Test - public void test01_Main() throws InterruptedException { - if( mainRun ) { + public void test00_Manual() throws InterruptedException { + if( manual ) { final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2()); caps.setAlphaBits(1); runTestGL(caps, globalNumSamples); @@ -212,17 +218,25 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { } @Test - public void test01() throws InterruptedException { - if( mainRun ) return ; + public void test01_startMSAA0() throws InterruptedException { + if( manual ) return ; final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2()); caps.setAlphaBits(1); runTestGL(caps, 0); } + @Test + public void test02_startMSAA4() throws InterruptedException { + if( manual ) return ; + final GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2()); + caps.setAlphaBits(1); + runTestGL(caps, 4); + } + public static void main(final String args[]) throws IOException { boolean waitForKey = false; - mainRun = true; + manual = false; for(int i=0; i0) { @@ -160,7 +160,7 @@ public class TextureDraw02ES2ListenerFBO implements GLEventListener { } private void resetFBOs(final GL gl, final int width, final int height) { - fbo0.reset(gl, width, height, numSamples, true); + fbo0.reset(gl, width, height, numSamples); numSamples = fbo0.getNumSamples(); if(numSamples>0) { fbo0Tex = fbo0.getSamplingSink().getTextureAttachment(); -- cgit v1.2.3