diff options
author | Sven Gothel <[email protected]> | 2013-10-25 01:39:51 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-25 01:39:51 +0200 |
commit | 7b6fe9e4d26b4d3ff2a9ffac12523bcd29196db0 (patch) | |
tree | bd4e0731aa93b908a72008deabe77825f9b0fe10 | |
parent | 4050d0a319e88d4795cdefd1fd84789430adc1a2 (diff) |
GLProfile: Fix native profile mapping, i.e. use actual mapped profile-impl as detected and mapped by GLContext ; Enhance glAvailabilityToString(..)
We shall not map profile == profile-impl, i.e. GL3 -> GL3,
but use GLContext.getAvailableGLProfileName(device, reqMajor, reqProfileBits).
The latter reflects the actual mapped context as detected.
glAvailabilityToString(..)
- Partition result in [Natives, Common and Mappings]
- Mappings dumps mapped keys to profiles, while excluding default.
Default is added at last.
- Add count.
-rw-r--r-- | make/scripts/tests.sh | 4 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLProfile.java | 129 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java | 12 |
3 files changed, 96 insertions, 49 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a1cb4d8e5..3f4fe9c19 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -300,7 +300,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -355,7 +355,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 35dcce0f7..c04971176 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -61,8 +61,8 @@ import javax.media.opengl.fixedfunc.GLPointerFunc; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; -import java.util.Iterator; import java.util.List; +import java.util.Map; /** * Specifies the the OpenGL profile. @@ -267,138 +267,182 @@ public class GLProfile { initSingleton(); + int allCount = 0; + int nativeCount = 0; + if(null==device) { device = defaultDevice; } final HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device, false); if(useIndent) { - doIndent(sb, indent, indentCount).append("Native"); + doIndent(sb, indent, indentCount).append("Natives"); indentCount++; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4bc").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc).append(indent); } else { - sb.append("Native[GL4bc "); + sb.append("Natives["+GL4bc+" "); } avail=isAvailableImpl(map, GL4bc); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4).append(indent); } else { - sb.append(", GL4 "); + sb.append(", "+GL4+" "); } avail=isAvailableImpl(map, GL4); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3).append(indent); } else { - sb.append(", GLES3 "); + sb.append(", "+GLES3+" "); } avail=isAvailableImpl(map, GLES3); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc).append(indent); } else { - sb.append(", GL3bc "); + sb.append(", "+GL3bc+" "); } avail=isAvailableImpl(map, GL3bc); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3).append(indent); } else { - sb.append(", GL3 "); + sb.append(", "+GL3+" "); } avail=isAvailableImpl(map, GL3); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_CORE); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2).append(indent); } else { - sb.append(", GL2 "); + sb.append(", "+GL2+" "); } avail=isAvailableImpl(map, GL2); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2).append(indent); } else { - sb.append(", GLES2 "); + sb.append(", "+GLES2+" "); } avail=isAvailableImpl(map, GLES2); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1).append(indent); } else { - sb.append(", GLES1 "); + sb.append(", "+GLES1+" "); } avail=isAvailableImpl(map, GLES1); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } + allCount++; + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+nativeCount+" / "+allCount); + indentCount--; + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Common"); + indentCount++; + } else { + sb.append(", count "+nativeCount+" / "+allCount+"], Common["); + } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3).append(indent); } else { - sb.append(", GL4ES3 "); + sb.append(", "+GL4ES3+" "); } sb.append(isAvailableImpl(map, GL4ES3)); + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3).append(indent); } else { - sb.append(", GL2ES2 "); + sb.append(", "+GL2GL3+" "); + } + sb.append(isAvailableImpl(map, GL2GL3)); + allCount++; + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2).append(indent); + } else { + sb.append(", "+GL2ES2+" "); } sb.append(isAvailableImpl(map, GL2ES2)); + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1).append(indent); } else { - sb.append(", GL2ES1 "); + sb.append(", "+GL2ES1+" "); } sb.append(isAvailableImpl(map, GL2ES1)); + allCount++; if(useIndent) { indentCount--; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles"); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Mappings"); indentCount++; } else { - sb.append("], Profiles["); + sb.append("], Mappings["); } + int profileCount = 0; + if(null != map) { - for(Iterator<GLProfile> i=map.values().iterator(); i.hasNext(); ) { - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount); - } - sb.append(i.next().toString()); - if(!useIndent) { - sb.append(", "); + for (Map.Entry<String,GLProfile> entry : map.entrySet()) { + if( !GL_DEFAULT.equals(entry.getKey()) ) { + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount); + } + sb.append(entry.getKey()+(useIndent?"\t":" ")+entry.getValue()); + if(!useIndent) { + sb.append(", "); + } + profileCount++; } } if(useIndent) { @@ -413,9 +457,10 @@ public class GLProfile { } } if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+profileCount+" / "+allCount); sb.append(Platform.getNewline()); } else { - sb.append("]"); + sb.append(", count "+profileCount+" / "+allCount+"]"); } return sb; @@ -1979,21 +2024,21 @@ public class GLProfile { } } } else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) { - return GL4bc; + return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT); } else if(GL4.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) { - return GL4; + return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE); } else if(GL3bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) { - return GL3bc; + return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT); } else if(GL3.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) { - return GL3; + return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE); } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) { - return GL2; + return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT); } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) { - return GLES3; + return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES); } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { - return GLES2; + return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES); } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) { - return GLES1; + return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES); } return null; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java index 7a48fbb2a..68562de4e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java @@ -3,14 +3,14 @@ * * 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 @@ -20,12 +20,12 @@ * 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 java.io.IOException; @@ -36,6 +36,7 @@ import org.junit.runners.MethodSorters; import javax.media.opengl.*; +import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.util.UITestCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -44,6 +45,7 @@ public class TestGLProfile00NEWT extends UITestCase { @Test public void testInitSingleton() throws InterruptedException { GLProfile.initSingleton(); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false)); } public static void main(String args[]) throws IOException { |