aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2009-03-19 20:08:15 +0000
committerKenneth Russel <[email protected]>2009-03-19 20:08:15 +0000
commitd84b348661f06005bc0a3e4306a9a24eaaebe4b5 (patch)
tree78a011ee29a39508135d76cf180ec80187914510 /src/jogl/classes/javax
parentfa014178e3f10e161610ce9c2e1cdb5d1b16ea32 (diff)
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
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java79
2 files changed, 51 insertions, 30 deletions
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<profiles.length; i++) {
profile = profiles[i];
+ computeRealProfile();
if (t == null) {
t = tryLibrary();
} else {
@@ -132,63 +163,53 @@ public class GLProfile {
/**
* Selects a profile, implementing the interface GL2ES1.
- * Order: GL2, GL2ES12, GLES1
+ * Order: GL2ES1, GL2, GLES1
*/
public static synchronized final void setProfileGL2ES1() {
- setProfile(new String[] { GL2, GL2ES12, GLES1 });
+ setProfile(new String[] { GL2ES1, GL2, GLES1 });
}
/**
* Selects a profile, implementing the interface GL2ES2.
- * Order: GL2, GL2ES12, GLES2
+ * Order: GL2ES2, GL2, GLES2
*/
public static synchronized final void setProfileGL2ES2() {
- setProfile(new String[] { GL2, GL2ES12, GLES2 });
+ setProfile(new String[] { GL2ES2, GL2, GLES2 });
}
/**
* Selects a profile, implementing the interface GL
- * Order: GL2, GL2ES12, GLES2, GLES1
+ * Order: GL2, GL2ES2, GL2ES1, GLES2, GLES1
*/
public static synchronized final void setProfileGLAny() {
- setProfile(new String[] { GL2, GL2ES12, GLES2, GLES1 });
+ setProfile(new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1 });
}
public static final String getProfile() {
return profile;
}
- /* true profile GL2ES12 */
- public static final boolean isGL2ES12() {
- return GL2ES12.equals(profile);
- }
-
- /* true profile GL2 */
public static final boolean isGL2() {
return GL2.equals(profile);
}
- /* true profile GLES1 */
public static final boolean isGLES1() {
return GLES1.equals(profile);
}
- /* true profile GLES2 */
public static final boolean isGLES2() {
return GLES2.equals(profile);
}
- /* abstract profile GL2ES12, GL2, GLES1 */
public static final boolean isGL2ES1() {
- return isGL2ES12() || isGL2() || isGLES1();
+ return GL2ES1.equals(profile);
}
- /* abstract profile GL2ES12, GL2, GLES2 */
public static final boolean isGL2ES2() {
- return isGL2ES12() || isGL2() || isGLES2();
+ return GL2ES2.equals(profile);
}
- /* abstract profile GLES1, GLES2 */
+ /** Indicates whether either of the OpenGL ES profiles are in use. */
public static final boolean isGLES() {
return isGLES2() || isGLES1();
}
@@ -200,7 +221,7 @@ public class GLProfile {
public static final String getGLImplBaseClassName() {
if(isGL2()) {
return "com.sun.opengl.impl.gl2.GL2";
- } else if(isGL2ES12()) {
+ } else if(isGL2ES1() || isGL2ES2()) {
return "com.sun.opengl.impl.gl2es12.GL2ES12";
} else if(isGLES1()) {
return "com.sun.opengl.impl.es1.GLES1";
@@ -277,7 +298,7 @@ public class GLProfile {
case javax.media.opengl.GL2.GL_2_BYTES:
case javax.media.opengl.GL2.GL_3_BYTES:
case javax.media.opengl.GL2.GL_4_BYTES:
- if( isGL2ES12() || isGL2() ) {
+ if( isGL2() ) {
return true;
}
}
@@ -403,7 +424,7 @@ public class GLProfile {
}
return false;
}
- } else if(GLProfile.isGL2ES12() || GLProfile.isGL2()) {
+ } else if(GLProfile.isGL2ES2() || GLProfile.isGL2()) {
if(isVertexAttribPointer) {
switch(type) {
case GL.GL_UNSIGNED_BYTE: