From 7dff066bb823dddb5d6e0e7672f5599afa5a43b9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 15:16:56 +0100 Subject: Add OSX CALayer OpenGL 3 (core) support: Derive pixelformat from parent (GL3), use GL3.2 compatible shader; Use VBO in general. Covered by: Auto unit tests: TestOffscreenLayer01GLCanvasAWT, TestOffscreenLayer02NewtCanvasAWT Manual: TestGearsES2AWT '-gl3 -layered' --- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 25 +++++++++++++--------- .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 25 +++++++++++++--------- 2 files changed, 30 insertions(+), 20 deletions(-) (limited to 'src/test/com/jogamp/opengl') diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java index b9e3f0606..90407166f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -41,6 +41,7 @@ import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import jogamp.nativewindow.jawt.JAWTUtil; @@ -122,22 +123,27 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { } @Test - public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(true); + public void test01_GLDefault() throws InterruptedException, InvocationTargetException { + testOffscreenLayerGLCanvas_Impl(null); } - private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { - if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { - System.err.println("onscreen layer n/a"); + @Test + public void test01_GL3() throws InterruptedException, InvocationTargetException { + if( !GLProfile.isAvailable(GLProfile.GL3) ) { + System.err.println("GL3 n/a"); return; } - if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + testOffscreenLayerGLCanvas_Impl(GLProfile.get(GLProfile.GL3)); + } + + private void testOffscreenLayerGLCanvas_Impl(GLProfile glp) throws InterruptedException, InvocationTargetException { + if(!JAWTUtil.isOffscreenLayerSupported()) { System.err.println("offscreen layer n/a"); return; } final Frame frame1 = new Frame("AWT Parent Frame"); - GLCapabilities caps = new GLCapabilities(null); + GLCapabilities caps = new GLCapabilities(glp); if(singleBuffer) { caps.setDoubleBuffered(false); } @@ -150,7 +156,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { caps.setOnscreen(true); // simulate normal behavior .. } final GLCanvas glc = new GLCanvas(caps); - glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + glc.setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported glc.setPreferredSize(preferredGLSize); glc.setMinimumSize(preferredGLSize); glc.setSize(preferredGLSize); @@ -165,8 +171,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { setupFrameAndShow(frame1, glc); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); - Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, - glc.isOffscreenLayerSurfaceEnabled()); + Assert.assertEquals(true, glc.isOffscreenLayerSurfaceEnabled()); GLAnimatorControl animator1 = new Animator(glc); if(!noAnimation) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java index ce90c77c5..e4a3bce71 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java @@ -41,6 +41,7 @@ import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; import jogamp.nativewindow.jawt.JAWTUtil; @@ -114,22 +115,27 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { } @Test - public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerNewtCanvas_Impl(true); + public void test01_GLDefault() throws InterruptedException, InvocationTargetException { + testOffscreenLayerNewtCanvas_Impl(null); } - private void testOffscreenLayerNewtCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { - if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { - System.err.println("onscreen layer n/a"); + @Test + public void test02_GL3() throws InterruptedException, InvocationTargetException { + if( !GLProfile.isAvailable(GLProfile.GL3) ) { + System.err.println("GL3 n/a"); return; } - if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + testOffscreenLayerNewtCanvas_Impl(GLProfile.get(GLProfile.GL3)); + } + + private void testOffscreenLayerNewtCanvas_Impl(GLProfile glp) throws InterruptedException, InvocationTargetException { + if(!JAWTUtil.isOffscreenLayerSupported()) { System.err.println("offscreen layer n/a"); return; } final Frame frame1 = new Frame("AWT Parent Frame"); - GLCapabilities caps = new GLCapabilities(null); + GLCapabilities caps = new GLCapabilities(glp); if(singleBuffer) { caps.setDoubleBuffered(false); } @@ -144,7 +150,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(caps); final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); - newtCanvasAWT1.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + newtCanvasAWT1.setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported newtCanvasAWT1.setPreferredSize(preferredGLSize); newtCanvasAWT1.setMinimumSize(preferredGLSize); newtCanvasAWT1.setSize(preferredGLSize); @@ -162,8 +168,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, - newtCanvasAWT1.isOffscreenLayerSurfaceEnabled()); + Assert.assertEquals(true, newtCanvasAWT1.isOffscreenLayerSurfaceEnabled()); GLAnimatorControl animator1 = new Animator(glWindow1); if(!noAnimation) { -- cgit v1.2.3