aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2008-05-28 02:37:45 +0000
committerKenneth Russel <[email protected]>2008-05-28 02:37:45 +0000
commit95c3974708231607d729830ae711a0864a961b71 (patch)
tree2fb2df4cdf04851b73234353538d2dd0dd087ed1 /src/classes/javax/media
parentfbcbb9ab19b0e2e85250f5e3653c3a3d7bf12e8d (diff)
Filled out EGLContext, EGLDrawable, and EGLDrawableFactory
implementations on top of autogenerated EGL binding. Added GLDrawableFactory.initialize(String) taking the profile name (PROFILE_GL_20, PROFILE_GLES1, and PROFILE_GLES2 defined in GLDrawableFactory) to bootstrap the system and allow run-time selection of the window system binding. Modified eglplatform.h to extend EGLNativeDisplayType to pointer size. Changed egl.cfg to change most EGL types to opaque longs. Still missing pieces include the function pointer lookup and autogeneration of the EGL binding in all situations. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1643 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax/media')
-rw-r--r--src/classes/javax/media/opengl/GLDrawableFactory.java115
1 files changed, 77 insertions, 38 deletions
diff --git a/src/classes/javax/media/opengl/GLDrawableFactory.java b/src/classes/javax/media/opengl/GLDrawableFactory.java
index 3945f42fc..42727fc48 100644
--- a/src/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/classes/javax/media/opengl/GLDrawableFactory.java
@@ -39,6 +39,7 @@
package javax.media.opengl;
+import java.lang.reflect.*;
import java.security.*;
import com.sun.opengl.impl.*;
@@ -78,60 +79,98 @@ import com.sun.opengl.impl.*;
public abstract class GLDrawableFactory {
private static GLDrawableFactory factory;
- protected GLDrawableFactory() {}
+ /** The desktop (OpenGL 2.0) profile */
+ public static final String PROFILE_GL_20 = "GL20";
- /** Returns the sole GLDrawableFactory instance. */
- public static GLDrawableFactory getFactory() {
- if (factory == null) {
+ /** The OpenGL ES 1 (really, 1.1) profile */
+ public static final String PROFILE_GLES1 = "GLES1";
- // FIXME: hook this in to the normal reflective mechanism
- factory = new com.sun.opengl.impl.egl.EGLDrawableFactory();
+ /** The OpenGL ES 2 (really, 2.0) profile */
+ public static final String PROFILE_GLES2 = "GLES2";
- /*
+ private String profile;
+ /** Initializes the sole GLDrawableFactory instance for the given profile. */
+ public static void initialize(String profile) throws GLException {
+ if (factory != null) {
+ throw new GLException("Already initialized");
+ }
+
+ // See if the user is requesting one of the embedded profiles,
+ // and if so, try to instantiate the EGLDrawableFactory
+ if (PROFILE_GLES1.equals(profile) ||
+ PROFILE_GLES2.equals(profile)) {
try {
- String factoryClassName =
- (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty("opengl.factory.class.name");
- }
- });
- String osName = System.getProperty("os.name");
- String osNameLowerCase = osName.toLowerCase();
- Class factoryClass = null;
+ Class clazz = Class.forName("com.sun.opengl.impl.egl.EGLDrawableFactory");
+ Constructor c = clazz.getDeclaredConstructor(new Class[] { String.class });
+ factory = (GLDrawableFactory) c.newInstance(new Object[] { profile });
+ } catch (Exception e) {
+ }
+ } else if (!PROFILE_GL_20.equals(profile)) {
+ // We require that the user passes in one of the known profiles
+ throw new GLException("Unknown or unsupported profile \"" + profile + "\"");
+ }
- // Because there are some complications with generating all
- // platforms' Java glue code on all platforms (among them that we
- // would have to include jawt.h and jawt_md.h in the jogl
- // sources, which we currently don't have to do) we break the only
- // static dependencies with platform-specific code here using reflection.
+ // Use the desktop OpenGL as the fallback always
+ try {
+ String factoryClassName =
+ (String) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return System.getProperty("opengl.factory.class.name");
+ }
+ });
+ String osName = System.getProperty("os.name");
+ String osNameLowerCase = osName.toLowerCase();
+ Class factoryClass = null;
- if (factoryClassName != null) {
- factoryClass = Class.forName(factoryClassName);
- } else if (osNameLowerCase.startsWith("wind")) {
- factoryClass = Class.forName("com.sun.opengl.impl.windows.WindowsGLDrawableFactory");
- } else if (osNameLowerCase.startsWith("mac os x")) {
- factoryClass = Class.forName("com.sun.opengl.impl.macosx.MacOSXGLDrawableFactory");
- } else {
- // Assume Linux, Solaris, etc. Should probably test for these explicitly.
- factoryClass = Class.forName("com.sun.opengl.impl.x11.X11GLDrawableFactory");
- }
+ // Because there are some complications with generating all
+ // platforms' Java glue code on all platforms (among them that we
+ // would have to include jawt.h and jawt_md.h in the jogl
+ // sources, which we currently don't have to do) we break the only
+ // static dependencies with platform-specific code here using reflection.
- if (factoryClass == null) {
- throw new GLException("OS " + osName + " not yet supported");
- }
+ if (factoryClassName != null) {
+ factoryClass = Class.forName(factoryClassName);
+ } else if (osNameLowerCase.startsWith("wind")) {
+ factoryClass = Class.forName("com.sun.opengl.impl.windows.WindowsGLDrawableFactory");
+ } else if (osNameLowerCase.startsWith("mac os x")) {
+ factoryClass = Class.forName("com.sun.opengl.impl.macosx.MacOSXGLDrawableFactory");
+ } else {
+ // Assume Linux, Solaris, etc. Should probably test for these explicitly.
+ factoryClass = Class.forName("com.sun.opengl.impl.x11.X11GLDrawableFactory");
+ }
- factory = (GLDrawableFactory) factoryClass.newInstance();
- } catch (Exception e) {
- throw new GLException(e);
+ if (factoryClass == null) {
+ throw new GLException("OS " + osName + " not yet supported");
}
- */
+ Constructor c = factoryClass.getDeclaredConstructor(new Class[] { String.class });
+ factory = (GLDrawableFactory) c.newInstance(new Object[] { profile });
+ } catch (Exception e) {
+ throw new GLException(e);
+ }
+ }
+
+ /** Creates a new GLDrawableFactory instance. End users do not need
+ to call this method. */
+ protected GLDrawableFactory(String profile) {
+ this.profile = profile;
+ }
+
+ /** Returns the sole GLDrawableFactory instance for the specified profile. */
+ public static GLDrawableFactory getFactory() {
+ if (factory == null) {
+ throw new GLException("Must call initialize() first");
}
return factory;
}
+ /** Indicates which profile this GLDrawableFactory was created for. */
+ public String getProfile() {
+ return profile;
+ }
+
/**
* <P> Selects a graphics configuration on the specified graphics
* device compatible with the supplied GLCapabilities. This method