From d84b348661f06005bc0a3e4306a9a24eaaebe4b5 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Thu, 19 Mar 2009 20:08:15 +0000 Subject: Removed GL2ES12 interface from the public API since it is only an implementation detail. Removed GL2ES12 queries from the GLProfile class. Changed GL2ES12 instance to pay attention to the chosen profile so it behaves only like either GL2ES1 or GL2ES2. Sven's fixed function emulation can now be tested on the desktop without needing OpenGL ES emulation libraries. However, there appear to be problems running it on top of Apple's OpenGL implementation -- seen by running demos.es1.RedSquare and demos.es1.angeles.Main forcing the use of the GL2ES2 profile. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1889 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../javax/media/opengl/GLDrawableFactory.java | 2 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 79 ++++++++++++++-------- 2 files changed, 51 insertions(+), 30 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 66585eb56..5a3f9f4e9 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -104,7 +104,7 @@ public abstract class GLDrawableFactory { } catch (Exception e) { e.printStackTrace(); } - } else if (!GLProfile.isGL2() && !GLProfile.isGL2ES12()) { + } else if (!GLProfile.isGL2() && !GLProfile.isGL2ES1() && !GLProfile.isGL2ES2()) { // We require that the user passes in one of the known profiles throw new GLException("Unknown or unsupported profile \"" + GLProfile.getProfile() + "\""); } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 625099e16..1ac09c12e 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -43,36 +43,55 @@ import com.sun.opengl.impl.*; import com.sun.nativewindow.impl.NWReflection; public class GLProfile { + // + // Public (user-visible) profiles + // + /** The desktop (OpenGL 2.0) profile */ public static final String GL2 = "GL2"; - /** The desktop short profile, intersecting: GL2+GLES1+GLES2 */ - public static final String GL2ES12 = "GL2ES12"; - /** The OpenGL ES 1 (really, 1.1) profile */ public static final String GLES1 = "GLES1"; /** The OpenGL ES 2 (really, 2.0) profile */ public static final String GLES2 = "GLES2"; + /** The intersection of the desktop (OpenGL 2.0) and OpenGL ES 1.x profiles */ + public static final String GL2ES1 = "GL2ES1"; + + /** The intersection of the desktop (OpenGL 2.0) and OpenGL ES 2.x profiles */ + public static final String GL2ES2 = "GL2ES2"; + + // + // Profiles which are implementation details + // + + // The intersection between desktop OpenGL and the union of the OpenGL ES profiles + // This is here only to avoid having separate GL2ES1Impl and GL2ES2Impl classes + private static final String GL2ES12 = "GL2ES12"; + /** The JVM/process wide chosen GL profile **/ private static String profile = null; + /** The "real" profile implementing the chosen profile; for example, + both GL2ES1 and GL2ES2 currently map to GL2ES12 */ + private static String realProfile = null; + private static final Throwable tryLibrary() { try { Class clazz = Class.forName(getGLImplBaseClassName()+"Impl"); - if(GL2.equals(profile)) { + if(GL2.equals(realProfile)) { // See DRIHack.java for an explanation of why this is necessary DRIHack.begin(); NativeLibLoader.loadGL2(); DRIHack.end(); - } if(GL2ES12.equals(profile)) { + } if(GL2ES12.equals(realProfile)) { // See DRIHack.java for an explanation of why this is necessary DRIHack.begin(); NativeLibLoader.loadGL2ES12(); DRIHack.end(); - } else if(GLES1.equals(profile) || GLES2.equals(profile)) { + } else if(GLES1.equals(realProfile) || GLES2.equals(realProfile)) { Object eGLDrawableFactory = NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory"); if(null==eGLDrawableFactory) { throw new GLException("com.sun.opengl.impl.egl.EGLDrawableFactory not available"); @@ -85,22 +104,33 @@ public class GLProfile { e.printStackTrace(); } profile=null; + realProfile = null; return e; } } + private static void computeRealProfile() { + if (GL2ES1.equals(profile) || + GL2ES2.equals(profile)) { + realProfile = GL2ES12; + } else { + realProfile = profile; + } + } + public static synchronized final void setProfile(String profile) throws GLException { if(null==GLProfile.profile) { GLProfile.profile = profile; + computeRealProfile(); Throwable t = tryLibrary(); if (GLProfile.profile == null) { throw new GLException("Profile " + profile + " not available", t); } } else { if(!GLProfile.profile.equals(profile)) { - throw new GLException("Chosen profile ("+profile+") doesn't match preset one: "+GLProfile.profile); + throw new GLException("Requested profile ("+profile+") doesn't match already chosen one: "+GLProfile.profile); } } } @@ -111,6 +141,7 @@ public class GLProfile { Throwable t = null; for(int i=0; profile==null && i