From 29ee4fa97a7e17fe2eb07797350200300d8126d7 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Fri, 24 Feb 2012 01:49:22 +0100
Subject: Add GLProfile.getGL2GL3() meta profile getter completing
 getGL2ES[12]()

---
 src/jogl/classes/javax/media/opengl/GLProfile.java |  32 ++++++
 .../test/junit/jogl/acore/TestMapBuffer01NEWT.java | 111 -------------------
 .../junit/jogl/acore/TestMapBufferRead01NEWT.java  | 121 +++++++++++++++++++++
 .../test/junit/jogl/glsl/TestFBOMRTNEWT01.java     |   2 +-
 .../texture/TestGrayTextureFromFileAWTBug417.java  |   6 +-
 .../test/junit/jogl/texture/TestTexture01AWT.java  |   6 +-
 6 files changed, 164 insertions(+), 114 deletions(-)
 delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java
 create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java

diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index d573fd3b1..1e7346116 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -666,6 +666,7 @@ public class GLProfile {
      * <p>Selection favors hardware rasterizer.</p>
      *
      * @throws GLException if no GL2ES1 compatible profile is available for the default device.
+     * @see #isGL2ES1()
      * @see #get(AbstractGraphicsDevice, String)
      * @see #getImpl()
      */
@@ -695,6 +696,7 @@ public class GLProfile {
      * <p>Selection favors hardware rasterizer.</p>
      *
      * @throws GLException if no GL2ES2 compatible profile is available for the default device.
+     * @see #isGL2ES2()
      * @see #get(AbstractGraphicsDevice, String)
      * @see #getImpl()
      */
@@ -715,6 +717,36 @@ public class GLProfile {
         return get(defaultDevice, GL2ES2).getImpl();
     }
 
+    /** 
+     * Returns the GL2GL3 profile implementation, hence compatible w/ GL2GL3.<br/>
+     * It returns:
+     * <pre>
+     *   GLProfile.get(device, GLProfile.GL2GL3).getImpl());
+     * </pre>
+     * <p>Selection favors hardware rasterizer.</p>
+     *
+     * @throws GLException if no GL2GL3 compatible profile is available for the default device.
+     * @see #isGL2GL3()
+     * @see #get(AbstractGraphicsDevice, String)
+     * @see #getImpl()
+     */
+    public static GLProfile getGL2GL3(AbstractGraphicsDevice device)
+        throws GLException
+    {
+        return get(device, GL2GL3).getImpl();
+    }
+
+    /** 
+     * Calls {@link #getGL2GL3(AbstractGraphicsDevice)} using the default device. 
+     * <p>Selection favors hardware rasterizer.</p>
+     * @see #getGL2GL3(AbstractGraphicsDevice)
+     */
+    public static GLProfile getGL2GL3()
+        throws GLException
+    {
+        return get(defaultDevice, GL2GL3).getImpl();
+    }
+
     /** Returns a GLProfile object.
      * verifies the given profile and chooses an appropriate implementation.
      * A generic value of <code>null</code> or <code>GL</code> will result in
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java
deleted file mode 100644
index bad04addc..000000000
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBuffer01NEWT.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright 2011 JogAmp Community. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- *    1. Redistributions of source code must retain the above copyright notice, this list of
- *       conditions and the following disclaimer.
- *
- *    2. Redistributions in binary form must reproduce the above copyright notice, this list
- *       of conditions and the following disclaimer in the documentation and/or other materials
- *       provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are those of the
- * authors and should not be interpreted as representing official policies, either expressed
- * or implied, of JogAmp Community.
- */
-package com.jogamp.opengl.test.junit.jogl.acore;
-
-import com.jogamp.common.nio.Buffers;
-import com.jogamp.opengl.test.junit.util.NEWTGLContext;
-import com.jogamp.opengl.test.junit.util.UITestCase;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2GL3;
-import javax.media.opengl.GLProfile;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- * @author Luz, et.al.
- */
-public class TestMapBuffer01NEWT extends UITestCase {
-    static final boolean DEBUG = false;
-    
-    @Test
-    public void testWriteRead01a() throws InterruptedException {
-        ByteBuffer verticiesBB = ByteBuffer.allocate(4*9);
-        verticiesBB.order(ByteOrder.nativeOrder());
-        testWriteRead01(verticiesBB);
-    }
-    @Test
-    public void testWriteRead01b() throws InterruptedException {
-        ByteBuffer verticiesBB = Buffers.newDirectByteBuffer(4*9);
-        testWriteRead01(verticiesBB);
-    }
-
-    private void testWriteRead01(ByteBuffer verticiesBB) throws InterruptedException {
-        final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getDefault(), 800, 600, true);
-        final GL gl = winctx.context.getGL();
-
-        int[] vertexBuffer = new int[1];
-        
-        verticiesBB.putFloat(0);
-        verticiesBB.putFloat(0.5f);
-        verticiesBB.putFloat(0);
-
-        verticiesBB.putFloat(0.5f);
-        verticiesBB.putFloat(-0.5f);
-        verticiesBB.putFloat(0);
-
-        verticiesBB.putFloat(-0.5f);
-        verticiesBB.putFloat(-0.5f);
-        verticiesBB.putFloat(0);
-        verticiesBB.rewind();
-        if(DEBUG) {
-            for(int i=0; i < verticiesBB.capacity(); i+=4) {
-                System.out.println("java "+i+": "+verticiesBB.getFloat(i));
-            }
-        }
-
-        gl.glGenBuffers(1, vertexBuffer, 0);
-
-        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer[0]);
-
-        // gl.glBufferData(GL3.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL3.GL_STATIC_READ);
-        gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_DRAW);
-        
-        ByteBuffer bb = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2GL3.GL_READ_ONLY);
-        // gl.glUnmapBuffer(GL3.GL_ARRAY_BUFFER);
-        if(DEBUG) {
-            for(int i=0; i < bb.capacity(); i+=4) {
-                System.out.println("gpu "+i+": "+bb.getFloat(i));
-            }
-        }
-        for(int i=0; i < bb.capacity(); i+=4) {
-            Assert.assertEquals(verticiesBB.getFloat(i), bb.getFloat(i), 0.0);
-        }
-        NEWTGLContext.destroyWindow(winctx);
-    }
-    public static void main(String args[]) throws IOException {
-        String tstname = TestMapBuffer01NEWT.class.getName();
-        org.junit.runner.JUnitCore.main(tstname);
-    }    
-}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
new file mode 100644
index 000000000..d264d4251
--- /dev/null
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMapBufferRead01NEWT.java
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2011 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ *    1. Redistributions of source code must retain the above copyright notice, this list of
+ *       conditions and the following disclaimer.
+ *
+ *    2. Redistributions in binary form must reproduce the above copyright notice, this list
+ *       of conditions and the following disclaimer in the documentation and/or other materials
+ *       provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl.test.junit.jogl.acore;
+
+import com.jogamp.common.nio.Buffers;
+import com.jogamp.opengl.test.junit.util.NEWTGLContext;
+import com.jogamp.opengl.test.junit.util.UITestCase;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+import javax.media.opengl.GL;
+import javax.media.opengl.GL2GL3;
+import javax.media.opengl.GLProfile;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author Luz, et.al.
+ */
+public class TestMapBufferRead01NEWT extends UITestCase {
+    static final boolean DEBUG = false;
+    
+    @Test
+    public void testWriteRead01a() throws InterruptedException {
+        if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+            System.err.println("Test requires GL2/GL3 profile.");
+            return;
+        }
+        ByteBuffer verticiesBB = ByteBuffer.allocate(4*9);
+        verticiesBB.order(ByteOrder.nativeOrder());
+        testWriteRead01(verticiesBB);
+    }
+    @Test
+    public void testWriteRead01b() throws InterruptedException {
+        if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+            System.err.println("Test requires GL2/GL3 profile.");
+            return;
+        }
+        ByteBuffer verticiesBB = Buffers.newDirectByteBuffer(4*9);
+        testWriteRead01(verticiesBB);
+    }
+
+    private void testWriteRead01(ByteBuffer verticiesBB) throws InterruptedException {
+        final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOffscreenWindow(GLProfile.getGL2GL3(), 800, 600, true);
+        final GL gl = winctx.context.getGL();
+
+        int[] vertexBuffer = new int[1];
+        
+        verticiesBB.putFloat(0);
+        verticiesBB.putFloat(0.5f);
+        verticiesBB.putFloat(0);
+
+        verticiesBB.putFloat(0.5f);
+        verticiesBB.putFloat(-0.5f);
+        verticiesBB.putFloat(0);
+
+        verticiesBB.putFloat(-0.5f);
+        verticiesBB.putFloat(-0.5f);
+        verticiesBB.putFloat(0);
+        verticiesBB.rewind();
+        if(DEBUG) {
+            for(int i=0; i < verticiesBB.capacity(); i+=4) {
+                System.out.println("java "+i+": "+verticiesBB.getFloat(i));
+            }
+        }
+
+        gl.glGenBuffers(1, vertexBuffer, 0);
+
+        gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vertexBuffer[0]);
+
+        // gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_READ);
+        gl.glBufferData(GL.GL_ARRAY_BUFFER, verticiesBB.capacity(), verticiesBB, GL.GL_STATIC_DRAW);
+        
+        ByteBuffer bb = gl.glMapBuffer(GL.GL_ARRAY_BUFFER, GL2GL3.GL_READ_ONLY);
+        Assert.assertNotNull(bb);
+        
+        if(DEBUG) {
+            for(int i=0; i < bb.capacity(); i+=4) {
+                System.out.println("gpu "+i+": "+bb.getFloat(i));
+            }
+        }
+        for(int i=0; i < bb.capacity(); i+=4) {
+            Assert.assertEquals(verticiesBB.getFloat(i), bb.getFloat(i), 0.0);
+        }
+        gl.glUnmapBuffer(GL.GL_ARRAY_BUFFER);
+        NEWTGLContext.destroyWindow(winctx);
+    }
+    public static void main(String args[]) throws IOException {
+        String tstname = TestMapBufferRead01NEWT.class.getName();
+        org.junit.runner.JUnitCore.main(tstname);
+    }    
+}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
index 50c398300..7227b0215 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestFBOMRTNEWT01.java
@@ -61,7 +61,7 @@ public class TestFBOMRTNEWT01 extends UITestCase {
             System.err.println("Test requires GL2/GL3 profile.");
             return;
         }
-        final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.get(GLProfile.GL2GL3), 640, 480, true);        
+        final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow(GLProfile.getGL2GL3(), 640, 480, true);        
         final GLDrawable drawable = winctx.context.getGLDrawable();
         GL2GL3 gl = winctx.context.getGL().getGL2GL3();
         gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ).getGL2GL3();
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java b/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java
index 8f38ac604..d43a3a0c5 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestGrayTextureFromFileAWTBug417.java
@@ -65,7 +65,11 @@ public class TestGrayTextureFromFileAWTBug417 extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        glp = GLProfile.get(GLProfile.GL2GL3);
+        if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+            UITestCase.setTestSupported(false);
+            return;
+        }
+        glp = GLProfile.getGL2GL3();
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
         Assert.assertNotNull(caps);
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java
index 49057643e..217b8aca3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/texture/TestTexture01AWT.java
@@ -61,7 +61,11 @@ public class TestTexture01AWT extends UITestCase {
 
     @BeforeClass
     public static void initClass() {
-        glp = GLProfile.get(GLProfile.GL2GL3);
+        if(!GLProfile.isAvailable(GLProfile.GL2GL3)) {
+            UITestCase.setTestSupported(false);
+            return;
+        }
+        glp = GLProfile.getGL2GL3();
         Assert.assertNotNull(glp);
         caps = new GLCapabilities(glp);
         Assert.assertNotNull(caps);
-- 
cgit v1.2.3