From fd418a69eca7b8c1bb74244982305fc6004d0a52 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Apr 2013 03:16:33 +0200 Subject: Fix Bug 720: Unify all platform specific GLContextImpl specializations; Fix Bug 719 - Windows BITMAP Offscreen Orientation is not propagated through API Fix Bug 719 - Windows BITMAP Offscreen Orientation is not propagated through API Depends on Bug 720, since cleaning up GLContextImpl* is required to move property 'GLContext.isGLOrientationFlippedVertical()' to 'GLDrawable.isGLOriented()' where it belongs! Windows BITMAP GLDrawable impl. isGLOriented() shall return false, while we keep the BITMAPINFOHEADER's height field negative to remove the need for vertical flip when used w/ AWT or Windows, .. Then property 'GLDrawable.isGLOriented()' has to be recognized throughout the utility functions, i.e. TextureData's mustFlipVertically and hence TextureIO writer. Fix Bug 720: Unify all platform specific GLContextImpl specializations GLContextImpl shall have only _one_ unique platform derivative to allow proper swapping of GLDrawables of any type via: - 'GLAutoDrawable.setContext(GLContext newCtx, boolean destroyPrevCtx)', which calls - 'GLContext.setGLDrawable(GLDrawable readWrite, boolean setWriteOnly)' Exception: External context may be specialized. All drawable specific property handling shall be provided and implemented (if possible) via GLDrawable specializations. - GLContext.isGLOrientationFlippedVertical() -> GLDrawable.isGLOriented() - PNGImage.createFromData() takes 'isGLOriented' to properly handle vertical flipping simply by line ordering - TextureIO's PNG writer passes TextureData's getMustFlipVertically() as isGLOriented to PNGImage.createFromData() - GLReadBufferUtil respects GLDrawable's isGLOriented() when creating TextureData instance. - Screenshot respects GLDrawable's isGLOriented() - Screenshot is deprecated, use GLReadBufferUtil. - Removed all PBuffer attributes, i.e. floatingPoint, RenderToTexture and RenderToTextureRectangle. - Allows removal of special pbuffer handling in GLContext* implementations. - Removed also from GLCapabilities* - Removed from deprecated GLPbuffer Impact: - Low, users who desire to render into a texture shall use our FBO GLOffscreenDrawable. - Only use case was the deprecated GLPbuffer - floating point framebuffer technology is still patented anyways :) - Removed Java2DGLContext, which was only used for OSX's GLJPanel Java2D bridge, which is no more supported anyways. --- .../jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java | 47 ++++++++++++++++++---- .../jogl/util/texture/TestPNGImage01NEWT.java | 41 ++++++++++++++----- 2 files changed, 71 insertions(+), 17 deletions(-) (limited to 'src/test/com') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java index 6221a1029..728b040af 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java @@ -107,7 +107,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { } } ) ; if( useAnimator ) { - animator.setUpdateFPSFrames(1, null); + animator.setUpdateFPSFrames(60, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); } @@ -117,13 +117,18 @@ public class TestGearsGLJPanelAWT extends UITestCase { new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - snap.setMakeSnapshot(); - final long t0 = System.currentTimeMillis(); long t1 = t0; + boolean triggerSnap = false; while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { Thread.sleep(100); t1 = System.currentTimeMillis(); + snap.getDisplayCount(); + if( !triggerSnap && snap.getDisplayCount() > 1 ) { + // Snapshot only after one frame has been rendered to suite FBO MSAA! + snap.setMakeSnapshot(); + triggerSnap = true; + } } Assert.assertNotNull(frame); @@ -145,7 +150,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { } @Test - public void test01_default() + public void test01_DefaultNorm() throws AWTException, InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); @@ -163,7 +168,7 @@ public class TestGearsGLJPanelAWT extends UITestCase { } @Test - public void test02_msaa() + public void test02_DefaultMsaa() throws AWTException, InterruptedException, InvocationTargetException { if( manualTest ) { @@ -176,25 +181,53 @@ public class TestGearsGLJPanelAWT extends UITestCase { } @Test - public void test03_pbuffer() + public void test03_PbufferNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setPBuffer(true); + runTestGL(caps); + } + + @Test + public void test04_PbufferMsaa() throws AWTException, InterruptedException, InvocationTargetException { if( manualTest ) { return; } GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); caps.setPBuffer(true); runTestGL(caps); } @Test - public void test04_bitmap() + public void test05_BitmapNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setBitmap(true); + runTestGL(caps); + } + + @Test + public void test06_BitmapMsaa() throws AWTException, InterruptedException, InvocationTargetException { if( manualTest ) { return; } GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); caps.setBitmap(true); runTestGL(caps); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java index 743d682c8..7b53d973c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java @@ -17,22 +17,43 @@ public class TestPNGImage01NEWT extends UITestCase { public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); + final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); + final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); + final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); - PNGImage image0 = PNGImage.read(urlConn.getInputStream()); - System.err.println("PNGImage - Orig: "+image0); - image0.write(out1_f, true); + PNGImage image1 = PNGImage.read(urlConn.getInputStream()); + System.err.println("PNGImage - Orig: "+image1); + image1.write(out1_f, true); { - Assert.assertEquals(image0.getData(), PNGImage.read(IOUtil.toURL(out1_f).openStream()).getData()); + Assert.assertEquals(image1.getData(), PNGImage.read(IOUtil.toURL(out1_f).openStream()).getData()); } - final PNGImage image1 = PNGImage.createFromData(image0.getWidth(), image0.getHeight(), - image0.getDpi()[0], image0.getDpi()[1], - image0.getBytesPerPixel(), false, image0.getData()); - image1.write(out2_f, true); + final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2.write(out2_f, true); { - Assert.assertEquals(image0.getData(), PNGImage.read(IOUtil.toURL(out2_f).openStream()).getData()); - } + Assert.assertEquals(image1.getData(), PNGImage.read(IOUtil.toURL(out2_f).openStream()).getData()); + } + + // flipped + final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2F.write(out2F_f, true); + + // reversed channels + final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2R.write(out2R_f, true); + + // reversed channels and flipped + final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2RF.write(out2RF_f, true); } public static void main(String args[]) { -- cgit v1.2.3