diff options
Diffstat (limited to 'src/jogl/classes/javax/media')
17 files changed, 730 insertions, 218 deletions
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index 5450e400b..ee41c9161 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -41,7 +41,7 @@ package javax.media.opengl; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindowException; -import com.sun.opengl.impl.Debug; +import com.jogamp.opengl.impl.Debug; /** <P> The default implementation of the {@link GLCapabilitiesChooser} interface, which provides consistent visual @@ -89,11 +89,17 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { int windowSystemRecommendedChoice) { GLCapabilities _desired = (GLCapabilities) desired; GLCapabilities[] _available = (GLCapabilities[]) available; + int availnum = 0; + + for (int i = 0; i < _available.length; i++) { + if(null != _available[i]) { availnum++; } + } if (DEBUG) { System.err.println("Desired: " + _desired); + System.err.println("Available: Valid " + availnum + "/" + _available.length); for (int i = 0; i < _available.length; i++) { - System.err.println("Available " + i + ": " + _available[i]); + System.err.println(i + ": " + _available[i]); } System.err.println("Window system's recommended choice: " + windowSystemRecommendedChoice); } @@ -132,6 +138,9 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { if (_desired.isOnscreen() != cur.isOnscreen()) { continue; } + if (!_desired.isOnscreen() && _desired.isPBuffer() && !cur.isPBuffer()) { + continue; // only skip if requested Offscreen && PBuffer, but no PBuffer available + } if (_desired.getStereo() != cur.getStereo()) { continue; } diff --git a/src/jogl/classes/javax/media/opengl/GLArrayData.java b/src/jogl/classes/javax/media/opengl/GLArrayData.java index d17ee6a06..088c71bd8 100644 --- a/src/jogl/classes/javax/media/opengl/GLArrayData.java +++ b/src/jogl/classes/javax/media/opengl/GLArrayData.java @@ -21,10 +21,10 @@ public interface GLArrayData { * The index of the predefined array index, see list below, * or -1 in case of a shader attribute array. * - * @see javax.media.opengl.GL#GL_VERTEX_ARRAY - * @see javax.media.opengl.GL#GL_NORMAL_ARRAY - * @see javax.media.opengl.GL#GL_COLOR_ARRAY - * @see javax.media.opengl.GL#GL_TEXTURE_COORD_ARRAY + * @see javax.media.opengl.GL2#GL_VERTEX_ARRAY + * @see javax.media.opengl.GL2#GL_NORMAL_ARRAY + * @see javax.media.opengl.GL2#GL_COLOR_ARRAY + * @see javax.media.opengl.GL2#GL_TEXTURE_COORD_ARRAY */ public int getIndex(); @@ -49,7 +49,7 @@ public interface GLArrayData { * Sets the determined location of the shader attribute * This is usually done within ShaderState. * - * @see javax.media.opengl.glsl.ShaderState#glVertexAttribPointer(GL2ES2, GLArrayData) + * @see com.jogamp.opengl.util.glsl.ShaderState#glVertexAttribPointer(GL2ES2, GLArrayData) */ public void setLocation(int v); diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index a94c14f33..7342369d9 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -40,7 +40,7 @@ package javax.media.opengl; import javax.media.opengl.glu.*; -import com.sun.opengl.impl.Debug; +import com.jogamp.opengl.impl.Debug; import java.security.*; /** A higher-level abstraction than {@link GLDrawable} which supplies diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index be5a6dc4f..5ba410a61 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -64,6 +64,20 @@ public interface GLBase { public boolean isGL(); /** + * Indicates whether this GL object conforms to the GL4 compatibility profile. + * The GL4 compatibility profile merges the GL2 profile and GL4 core profile. + * @return whether this GL object conforms to the GL4 compatibility profile + */ + public boolean isGL4bc(); + + /** + * Indicates whether this GL object conforms to the GL4 core profile. + * The GL4 core profile reflects OpenGL versions greater or equal 3.1 + * @return whether this GL object conforms to the GL4 core profile + */ + public boolean isGL4(); + + /** * Indicates whether this GL object conforms to the GL3 compatibility profile. * The GL3 compatibility profile merges the GL2 profile and GL3 core profile. * @return whether this GL object conforms to the GL3 compatibility profile @@ -131,6 +145,20 @@ public interface GLBase { public GL getGL() throws GLException; /** + * Casts this object to the GL4bc interface. + * @return this object cast to the GL4bc interface + * @throws GLException if this GLObject is not a GL4bc implementation + */ + public GL4bc getGL4bc() throws GLException; + + /** + * Casts this object to the GL4 interface. + * @return this object cast to the GL4 interface + * @throws GLException if this GLObject is not a GL4 implementation + */ + public GL4 getGL4() throws GLException; + + /** * Casts this object to the GL3bc interface. * @return this object cast to the GL3bc interface * @throws GLException if this GLObject is not a GL3bc implementation @@ -220,7 +248,7 @@ public interface GLBase { * * @param glFunctionName the name of the OpenGL function (e.g., use * "glBindRenderbufferEXT" or "glBindRenderbuffer" to check if {@link - * #glBindRenderbuffer(int,int)} is available). + * GL#glBindRenderbuffer(int,int)} is available). */ public boolean isFunctionAvailable(String glFunctionName); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 840de4764..2709dd506 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -39,8 +39,8 @@ package javax.media.opengl; -import com.sun.opengl.impl.Debug; import java.util.HashMap; +import com.jogamp.common.util.IntIntHashMap; /** Abstraction for an OpenGL rendering context. In order to perform OpenGL rendering, a context must be "made current" on the current @@ -67,6 +67,8 @@ public abstract class GLContext { private HashMap/*<int, Object>*/ attachedObjects = new HashMap(); + protected long context; + /** * Returns the GLDrawable to which this context may be used to * draw. @@ -136,14 +138,14 @@ public abstract class GLContext { * copied. <code>mask</code> contains the bitwise OR of the same * symbolic names that are passed to the GL command {@link * GL#glPushAttrib glPushAttrib}. The single symbolic constant - * {@link GL#GL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS} can be used to + * {@link GL2#GL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS} can be used to * copy the maximum possible portion of rendering state. <P> * * Not all values for GL state can be copied. For example, pixel * pack and unpack state, render mode state, and select and feedback * state are not copied. The state that can be copied is exactly the * state that is manipulated by the GL command {@link - * GL#glPushAttrib glPushAttrib}. <P> + * GL2#glPushAttrib glPushAttrib}. <P> * * On most platforms, this context may not be current to any thread, * including the calling thread, when this method is called. Some @@ -164,7 +166,7 @@ public abstract class GLContext { * If no context is current, throw an GLException * * @return the current context's GL object on this thread - * @thows GLException if no context is current + * @throws GLException if no context is current */ public static GL getCurrentGL() throws GLException { GLContext glc = getCurrent(); @@ -259,7 +261,15 @@ public abstract class GLContext { public final String toString() { StringBuffer sb = new StringBuffer(); sb.append(getClass().getName()); - sb.append(" ["); + sb.append(" [OpenGL "); + sb.append(getGLVersionMajor()); + sb.append("."); + sb.append(getGLVersionMinor()); + sb.append(", options 0x"); + sb.append(Integer.toHexString(ctxOptions)); + sb.append(", "); + sb.append(getGLVersion()); + sb.append(", "); sb.append(getGL()); if(getGLDrawable()!=getGLDrawableRead()) { sb.append(",\n\tDrawable Read : "); @@ -279,4 +289,241 @@ public abstract class GLContext { GLX) extensions. Can only be called while this context is current. */ public abstract String getPlatformExtensionsString(); + + public final int getGLVersionMajor() { return ctxMajorVersion; } + public final int getGLVersionMinor() { return ctxMinorVersion; } + public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); } + public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); } + public final boolean isCreatedWithARBMethod() { return ( 0 != ( CTX_IS_ARB_CREATED & ctxOptions ) ); } + + /** + * Returns a valid OpenGL version string, ie + * <code>major.minor ([option]?[options,]*) - gl-version</code> + * + * <ul> + * <li> options + * <ul> + * <li> <code>old</code> refers to the non ARB_create_context created context + * <li> <code>new</code> refers to the ARB_create_context created context + * <li> <code>compatible profile</code> + * <li> <code>core profile</code> + * <li> <code>forward compatible</code> + * <li> <code>any</code> refers to the non forward compatible context + * <li> <code>ES</code> refers to the GLES context variant + * </ul> + * <li> <i>gl-version</i> the GL_VERSION string + * </ul> + * + * e.g.: + * <table border="0"> + * <tr> <td></td> <td></td> </tr> + * <tr> + * <td>row 2, cell 1</td> + * <td>row 2, cell 2</td> + * </tr> + * </table> + * + * <table border="0"> + * <tr><td></td> <td>ES2</td> <td><code>2.0 (ES, any, new) - 2.0 ES Profile</code></td></tr> + * <tr><td>ATI</td><td>GL2</td> <td><code>3.0 (compatibility profile, any, new) - 3.2.9704 Compatibility Profile Context</code></td></tr> + * <tr><td>ATI</td><td>GL3</td> <td><code>3.3 (core profile, any, new) - 1.4 (3.2.9704 Compatibility Profile Context)</code></td></tr> + * <tr><td>ATI</td><td>GL3bc</td><td><code>3.3 (compatibility profile, any, new) - 1.4 (3.2.9704 Compatibility Profile Context)</code></td></tr> + * <tr><td>NV</td><td>GL2</td> <td><code>3.0 (compatibility profile, any, new) - 3.0.0 NVIDIA 195.36.07.03</code></td></tr> + * <tr><td>NV</td><td>GL3</td> <td><code>3.3 (core profile, any, new) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr> + * <tr><td>NV</td><td>GL3bc</td> <td><code>3.3 (compatibility profile, any, new) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr> + * </table> + */ + public final String getGLVersion() { + return ctxVersionString; + } + + protected int ctxMajorVersion=-1; + protected int ctxMinorVersion=-1; + protected int ctxOptions=0; + protected String ctxVersionString=null; + + /** <code>ARB_create_context</code> related: created via ARB_create_context */ + protected static final int CTX_IS_ARB_CREATED = 1 << 0; + /** <code>ARB_create_context</code> related: compatibility profile */ + protected static final int CTX_PROFILE_COMPAT = 1 << 1; + /** <code>ARB_create_context</code> related: core profile */ + protected static final int CTX_PROFILE_CORE = 1 << 2; + /** <code>ARB_create_context</code> related: flag forward compatible */ + protected static final int CTX_PROFILE_ES = 1 << 3; + /** <code>ARB_create_context</code> related: flag forward compatible */ + protected static final int CTX_OPTION_FORWARD = 1 << 4; + /** <code>ARB_create_context</code> related: not flag forward compatible */ + protected static final int CTX_OPTION_ANY = 1 << 5; + /** <code>ARB_create_context</code> related: flag debug */ + protected static final int CTX_OPTION_DEBUG = 1 << 6; + + + public final boolean isGL4bc() { + return ctxMajorVersion>=4 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES)); + } + + public final boolean isGL4() { + return ctxMajorVersion>=4 && 0==(ctxOptions & (CTX_PROFILE_ES)); + } + + public final boolean isGL3bc() { + return ctxMajorVersion>=3 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES)); + } + + public final boolean isGL3() { + return ctxMajorVersion>=3 && 0==(ctxOptions & (CTX_PROFILE_ES)); + } + + public final boolean isGL2() { + return ctxMajorVersion>=1 && CTX_PROFILE_COMPAT==(ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_ES)); + } + + public final boolean isGL2GL3() { + return isGL2() || isGL3(); + } + + public final boolean isGLES1() { + return ctxMajorVersion==1 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES); + } + + public final boolean isGLES2() { + return ctxMajorVersion==2 && CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES); + } + + public final boolean isGLES() { + return CTX_PROFILE_ES==(ctxOptions & CTX_PROFILE_ES); + } + + public final boolean isGL2ES1() { + return isGL2() || isGLES1() ; + } + + public final boolean isGL2ES2() { + return isGL2GL3() || isGLES2() ; + } + + public final boolean hasGLSL() { + return isGL2ES2() ; + } + + public static final int GL_VERSIONS[][] = { + /* 0.*/ { -1 }, + /* 1.*/ { 0, 1, 2, 3, 4, 5 }, + /* 2.*/ { 0, 1 }, + /* 3.*/ { 0, 1, 2, 3 }, + /* 4.*/ { 0 } }; + + public static final int getMaxMajor() { + return GL_VERSIONS.length-1; + } + + public static final int getMaxMinor(int major) { + if(1>major || major>=GL_VERSIONS.length) return -1; + return GL_VERSIONS[major].length-1; + } + + public static final boolean isValidGLVersion(int major, int minor) { + if(1>major || major>=GL_VERSIONS.length) return false; + if(0>minor || minor>=GL_VERSIONS[major].length) return false; + return true; + } + + public static final boolean decrementGLVersion(int major[], int minor[]) { + if(null==major || major.length<1 ||null==minor || minor.length<1) { + throw new GLException("invalid array arguments"); + } + int m = major[0]; + int n = minor[0]; + if(!isValidGLVersion(m, n)) return false; + + // decrement .. + n -= 1; + if(n < 0) { + m -= 1; + n = GL_VERSIONS[m].length-1; + } + if(!isValidGLVersion(m, n)) return false; + major[0]=m; + minor[0]=n; + + return true; + } + + public static final boolean isGLVersionAvailable(int major, boolean compatibility) { + int key = compose8bit(major, compatibility?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0); + int val = mappedVersionsAvailable.get( key ); + return val>0; + } + public static final boolean isGL4bcAvailable() { return isGLVersionAvailable(4, true); } + public static final boolean isGL4Available() { return isGLVersionAvailable(4, false); } + public static final boolean isGL3bcAvailable() { return isGLVersionAvailable(3, true); } + public static final boolean isGL3Available() { return isGLVersionAvailable(3, false); } + public static final boolean isGL2Available() { return isGLVersionAvailable(2, true); } + + protected static final IntIntHashMap mappedVersionsAvailable; + protected static volatile boolean mappedVersionsAvailableSet; + protected static Object mappedVersionsAvailableLock; + + static { + mappedVersionsAvailableLock = new Object(); + mappedVersionsAvailableSet = false; + mappedVersionsAvailable = new IntIntHashMap(); + mappedVersionsAvailable.setKeyNotFoundValue(-1); + } + + /** + * Called by {@link GLContextImpl#createContextARBMapVersionsAvailable} not intendet to be used by + * implementations. However, if {@link #createContextARB} is not being used within the + * {@link GLDrawableImpl} constructor, GLProfile has to map the available versions. + * + * @see #createContextARBMapVersionsAvailable + */ + protected static void mapVersionAvailable(int reqMajor, boolean reqCompat, int resMajor, int resMinor, int resCtp) + { + int key = compose8bit(reqMajor, reqCompat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, 0, 0); + int val = compose8bit(resMajor, resMinor, resCtp, 0); + mappedVersionsAvailable.put( key, val ); + } + + protected static int compose8bit(int one, int two, int three, int four) { + return ( ( one & 0x000000FF ) << 24 ) | + ( ( two & 0x000000FF ) << 16 ) | + ( ( three & 0x000000FF ) << 8 ) | + ( ( four & 0x000000FF ) ) ; + } + + protected static int getComposed8bit(int bits32, int which ) { + switch (which) { + case 1: return ( bits32 & 0xFF000000 ) >> 24 ; + case 2: return ( bits32 & 0x00FF0000 ) >> 16 ; + case 3: return ( bits32 & 0x0000FF00 ) >> 8 ; + case 4: return ( bits32 & 0xFF0000FF ) ; + } + throw new GLException("argument which out of range: "+which); + } + + protected static String composed8BitToString(int bits32, boolean hex1, boolean hex2, boolean hex3, boolean hex4) { + int a = getComposed8bit(bits32, 1); + int b = getComposed8bit(bits32, 2); + int c = getComposed8bit(bits32, 3); + int d = getComposed8bit(bits32, 4); + return "["+toString(a, hex1)+", "+toString(b, hex2)+", "+toString(c, hex3)+", "+toString(d, hex4)+"]"; + } + + protected static String toString(int val, boolean hex) { + if(hex) { + return "0x" + Integer.toHexString(val); + } + return String.valueOf(val); + } + + protected static String toHexString(int hex) { + return "0x" + Integer.toHexString(hex); + } + + protected static String toHexString(long hex) { + return "0x" + Long.toHexString(hex); + } + } + diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index b7c81cbed..b02bffb61 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -41,10 +41,10 @@ package javax.media.opengl; import javax.media.nativewindow.*; -import java.lang.reflect.*; import java.security.*; -import com.sun.opengl.impl.*; -import com.sun.nativewindow.impl.NWReflection; +import com.jogamp.common.JogampRuntimeException; +import com.jogamp.common.util.*; +import com.jogamp.opengl.impl.*; /** <P> Provides a virtual machine- and operating system-independent mechanism for creating {@link GLDrawable}s. </P> @@ -88,8 +88,8 @@ public abstract class GLDrawableFactory { private static final GLDrawableFactory eglFactory; private static final GLDrawableFactory nativeOSFactory; private static final String nativeOSType; - static final String macosxFactoryClassNameCGL = "com.sun.opengl.impl.macosx.cgl.MacOSXCGLDrawableFactory"; - static final String macosxFactoryClassNameAWTCGL = "com.sun.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory"; + static final String macosxFactoryClassNameCGL = "com.jogamp.opengl.impl.macosx.cgl.MacOSXCGLDrawableFactory"; + static final String macosxFactoryClassNameAWTCGL = "com.jogamp.opengl.impl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory"; /** * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones. @@ -97,51 +97,50 @@ public abstract class GLDrawableFactory { static { GLDrawableFactory tmp = null; try { - tmp = (GLDrawableFactory) NWReflection.createInstance("com.sun.opengl.impl.egl.EGLDrawableFactory"); - } catch (Throwable t) { + tmp = (GLDrawableFactory) ReflectionUtil.createInstance("com.jogamp.opengl.impl.egl.EGLDrawableFactory"); + } catch (JogampRuntimeException jre) { if (GLProfile.DEBUG) { System.err.println("GLDrawableFactory.static - EGLDrawableFactory - not available"); - t.printStackTrace(); + jre.printStackTrace(); } } eglFactory = tmp; nativeOSType = NativeWindowFactory.getNativeWindowType(true); - String factoryClassName = null; tmp = null; - try { - factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext()); - if (null == factoryClassName) { - if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) { - factoryClassName = "com.sun.opengl.impl.x11.glx.X11GLXDrawableFactory"; - } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) { - factoryClassName = "com.sun.opengl.impl.windows.wgl.WindowsWGLDrawableFactory"; - } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_MACOSX) ) { - if(NWReflection.isClassAvailable(macosxFactoryClassNameAWTCGL)) { - factoryClassName = macosxFactoryClassNameAWTCGL; - } else { - factoryClassName = macosxFactoryClassNameCGL; - } + String factoryClassName = Debug.getProperty("jogl.gldrawablefactory.class.name", true, AccessController.getContext()); + if (null == factoryClassName) { + if ( nativeOSType.equals(NativeWindowFactory.TYPE_X11) ) { + factoryClassName = "com.jogamp.opengl.impl.x11.glx.X11GLXDrawableFactory"; + } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_WINDOWS) ) { + factoryClassName = "com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory"; + } else if ( nativeOSType.equals(NativeWindowFactory.TYPE_MACOSX) ) { + if(ReflectionUtil.isClassAvailable(macosxFactoryClassNameAWTCGL)) { + factoryClassName = macosxFactoryClassNameAWTCGL; } else { - // may use egl*Factory .. - if (GLProfile.DEBUG) { - System.err.println("GLDrawableFactory.static - No native OS Factory for: "+nativeOSType+"; May use EGLDrawableFactory, if available." ); - } + factoryClassName = macosxFactoryClassNameCGL; } - } - if (null != factoryClassName) { + } else { + // may use egl*Factory .. if (GLProfile.DEBUG) { - System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName); + System.err.println("GLDrawableFactory.static - No native OS Factory for: "+nativeOSType+"; May use EGLDrawableFactory, if available." ); } - tmp = (GLDrawableFactory) NWReflection.createInstance(factoryClassName); - } - } catch (Throwable t) { - if (GLProfile.DEBUG) { - System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName); - t.printStackTrace(); } } + if (null != factoryClassName) { + if (GLProfile.DEBUG) { + System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nativeOSType+": "+factoryClassName); + } + try { + tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName); + } catch (JogampRuntimeException jre) { + if (GLProfile.DEBUG) { + System.err.println("GLDrawableFactory.static - Native Platform: "+nativeOSType+" - not available: "+factoryClassName); + jre.printStackTrace(); + } + } + } nativeOSFactory = tmp; } @@ -174,8 +173,7 @@ public abstract class GLDrawableFactory { destroy any GLContexts and GLDrawables that have been created and are still in use. No further OpenGL calls may be made after shutting down the GLDrawableFactory. */ - public void shutdown() { - } + public abstract void shutdown(); //---------------------------------------------------------------------- // Methods to create high-level objects @@ -187,10 +185,10 @@ public abstract class GLDrawableFactory { * The native platform's chosen Capabilties are referenced within the target * NativeWindow's AbstractGraphicsConfiguration.<p> * - * In case {@link javax.media.nativewindow.Capabilties#isOnscreen()} is true,<br> + * In case {@link javax.media.nativewindow.Capabilities#isOnscreen()} is true,<br> * an onscreen GLDrawable will be realized. * <p> - * In case {@link javax.media.nativewindow.Capabilties#isOnscreen()} is false,<br> + * In case {@link javax.media.nativewindow.Capabilities#isOnscreen()} is false,<br> * either a Pbuffer drawable is created if {@link javax.media.opengl.GLCapabilities#isPBuffer()} is true,<br> * or a simple offscreen drawable is creates. The latter is unlikely to be hardware accelerated.<br> * <p> @@ -218,8 +216,9 @@ public abstract class GLDrawableFactory { /** * Returns true if it is possible to create a GLPbuffer. Some older * graphics cards do not have this capability. + * @param passing the device for the query, may be null */ - public abstract boolean canCreateGLPbuffer(); + public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); /** * Creates a Pbuffer GLDrawable with the given capabilites and dimensions. <P> @@ -280,8 +279,9 @@ public abstract class GLDrawableFactory { /** * Returns true if it is possible to create an external GLDrawable * object via {@link #createExternalGLDrawable}. + * @param passing the device for the query, may be null */ - public abstract boolean canCreateExternalGLDrawable(); + public abstract boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device); /** * <P> Creates a {@link GLDrawable} object representing an existing diff --git a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java index 63b50cb3c..352545849 100644 --- a/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLPipelineFactory.java @@ -39,7 +39,7 @@ package javax.media.opengl; import java.lang.reflect.*; import java.util.StringTokenizer; -import com.sun.opengl.impl.*; +import com.jogamp.opengl.impl.*; /** * Factory for pipelining GL instances diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 69cdd3f24..0e10b32b3 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -36,13 +36,16 @@ package javax.media.opengl; -import javax.media.opengl.fixedfunc.*; -import java.lang.reflect.*; +import com.jogamp.common.util.*; +import com.jogamp.opengl.impl.DRIHack; +import com.jogamp.opengl.impl.Debug; +import com.jogamp.opengl.impl.GLJNILibLoader; +import com.jogamp.common.jvm.JVMUtil; import java.util.HashMap; -import java.security.*; -import com.sun.opengl.impl.*; -import com.sun.nativewindow.impl.NWReflection; -import com.sun.nativewindow.impl.jvm.JVMUtil; +import java.util.Iterator; +import java.security.AccessControlContext; +import java.security.AccessController; +import javax.media.opengl.fixedfunc.GLPointerFunc; /** * Specifies the the OpenGL profile. @@ -57,9 +60,62 @@ public class GLProfile implements Cloneable { public static final boolean DEBUG = Debug.debug("GLProfile"); // + // Query platform available OpenGL implementation + // + + public static final boolean isGL4bcAvailable() { return null != mappedProfiles.get(GL4bc); } + public static final boolean isGL4Available() { return null != mappedProfiles.get(GL4); } + public static final boolean isGL3bcAvailable() { return null != mappedProfiles.get(GL3bc); } + public static final boolean isGL3Available() { return null != mappedProfiles.get(GL3); } + public static final boolean isGL2Available() { return null != mappedProfiles.get(GL2); } + public static final boolean isGLES2Available() { return null != mappedProfiles.get(GLES2); } + public static final boolean isGLES1Available() { return null != mappedProfiles.get(GLES1); } + public static final boolean isGL2ES1Available() { return null != mappedProfiles.get(GL2ES1); } + public static final boolean isGL2ES2Available() { return null != mappedProfiles.get(GL2ES2); } + + public static final String glAvailabilityToString() { + StringBuffer sb = new StringBuffer(); + sb.append("GLAvailability[Native[GL4bc "); + sb.append(isGL4bcAvailable()); + sb.append(", GL4 "); + sb.append(isGL4Available()); + sb.append(", GL3bc "); + sb.append(isGL3bcAvailable()); + sb.append(", GL3 "); + sb.append(isGL3Available()); + sb.append(", GL2 "); + sb.append(isGL2Available()); + sb.append(", GL2ES1 "); + sb.append(isGL2ES1Available()); + sb.append(", GLES1 "); + sb.append(isGLES1Available()); + sb.append(", GL2ES2 "); + sb.append(isGL2ES2Available()); + sb.append(", GLES2 "); + sb.append(isGLES2Available()); + sb.append("], Profiles["); + for(Iterator i=mappedProfiles.values().iterator(); i.hasNext(); ) { + sb.append(((GLProfile)i.next()).toString()); + sb.append(", "); + } + sb.append(", default "); + sb.append(defaultGLProfile); + sb.append("]]"); + + return sb.toString(); + } + + // // Public (user-visible) profiles // + /** The desktop OpenGL compatibility profile 4.x, with x >= 0, ie GL2 plus GL4.<br> + <code>bc</code> stands for backward compatibility. */ + public static final String GL4bc = "GL4bc"; + + /** The desktop OpenGL core profile 4.x, with x >= 0 */ + public static final String GL4 = "GL4"; + /** The desktop OpenGL compatibility profile 3.x, with x >= 1, ie GL2 plus GL3.<br> <code>bc</code> stands for backward compatibility. */ public static final String GL3bc = "GL3bc"; @@ -86,22 +142,92 @@ public class GLProfile implements Cloneable { public static final String GL2GL3 = "GL2GL3"; /** - * All GL Profiles in the order of default detection: GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3 + * All GL Profiles in the order of default detection. + * Desktop compatibility profiles (the one with fixed function pipeline) comes first. + * + * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available! + * + * <ul> + * <li> GL2 + * <li> GL3bc + * <li> GL4bc + * <li> GL2GL3 + * <li> GL3 + * <li> GL4 + * <li> GL2ES2 + * <li> GLES2 + * <li> GL2ES1 + * <li> GLES1 + * </ul> + * + */ + public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL3bc, GL4bc, GL2GL3, GL3, GL4, GL2ES2, GLES2, GL2ES1, GLES1 }; + + /** + * Order of maximum fixed function profiles + * + * <ul> + * <li> GL4bc + * <li> GL3bc + * <li> GL2 + * <li> GL2ES1 + * <li> GLES1 + * </ul> + * + */ + public static final String[] GL_PROFILE_LIST_MAX_FIXEDFUNC = new String[] { GL4bc, GL3bc, GL2, GL2ES1, GLES1 }; + + /** + * Order of maximum programmable shader profiles + * + * <ul> + * <li> GL4 + * <li> GL4bc + * <li> GL3 + * <li> GL3bc + * <li> GL2 + * <li> GL2ES2 + * <li> GLES2 + * </ul> + * */ - public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL2, GL2ES2, GL2ES1, GLES2, GLES1, GL2GL3, GL3bc, GL3 }; + public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4, GL4bc, GL3, GL3bc, GL2, GL2ES2, GLES2 }; /** - * All GL2ES2 Profiles in the order of default detection: GL2ES2, GL2, GLES2, GL3 + * All GL2ES2 Profiles in the order of default detection. + * + * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available! + * + * <ul> + * <li> GL2ES2 + * <li> GL2 + * <li> GL3 + * <li> GL4 + * <li> GLES2 + * </ul> + * */ - public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GLES2, GL3bc, GL3 }; + public static final String[] GL_PROFILE_LIST_GL2ES2 = new String[] { GL2ES2, GL2, GL3, GL4, GLES2 }; /** - * All GL2ES1 Profiles in the order of default detection: GL2ES1, GL2, GLES1 + * All GL2ES1 Profiles in the order of default detection. + * + * FIXME GL3GL4: Due to GL3 and GL4 implementation bugs, we still choose GL2 first, if available! + * + * <ul> + * <li> GL2ES1 + * <li> GL2 + * <li> GL3bc + * <li> GL4bc + * <li> GLES1 + * </ul> + * */ - public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GLES1 }; + public static final String[] GL_PROFILE_LIST_GL2ES1 = new String[] { GL2ES1, GL2, GL3bc, GL4bc, GLES1 }; /** Returns a default GLProfile object, reflecting the best for the running platform. * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL} + * @see #GL_PROFILE_LIST_ALL */ public static final GLProfile getDefault() { if(null==defaultGLProfile) { @@ -110,22 +236,30 @@ public class GLProfile implements Cloneable { return defaultGLProfile; } - /** Returns a GLProfile object. - * Verfifies the given profile and chooses an apropriate implementation. - * A generic value of <code>null</code> or <code>GL</code> will result in - * the default profile. + /** + * Returns the highest profile, implementing the fixed function pipeline + * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_FIXEDFUNC} * * @throws GLException if no implementation for the given profile is found. + * @see #GL_PROFILE_LIST_MAX_FIXEDFUNC */ - public static final GLProfile get(String profile) + public static final GLProfile getMaxFixedFunc() throws GLException { - if(null==profile || profile.equals("GL")) return getDefault(); - GLProfile glProfile = (GLProfile) mappedProfiles.get(profile); - if(null==glProfile) { - throw new GLException("No implementation for profile "+profile+" available"); - } - return glProfile; + return get(GL_PROFILE_LIST_MAX_FIXEDFUNC); + } + + /** + * Returns the highest profile, implementing the programmable shader pipeline. + * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_MAX_PROGSHADER} + * + * @throws GLException if no implementation for the given profile is found. + * @see #GL_PROFILE_LIST_MAX_PROGSHADER + */ + public static final GLProfile getMaxProgrammable() + throws GLException + { + return get(GL_PROFILE_LIST_MAX_PROGSHADER); } /** @@ -133,6 +267,7 @@ public class GLProfile implements Cloneable { * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES1} * * @throws GLException if no implementation for the given profile is found. + * @see #GL_PROFILE_LIST_GL2ES1 */ public static final GLProfile getGL2ES1() throws GLException @@ -145,6 +280,7 @@ public class GLProfile implements Cloneable { * It selects the first of the set: {@link GLProfile#GL_PROFILE_LIST_GL2ES2} * * @throws GLException if no implementation for the given profile is found. + * @see #GL_PROFILE_LIST_GL2ES2 */ public static final GLProfile getGL2ES2() throws GLException @@ -152,6 +288,24 @@ public class GLProfile implements Cloneable { return get(GL_PROFILE_LIST_GL2ES2); } + /** Returns a GLProfile object. + * Verfifies the given profile and chooses an apropriate implementation. + * A generic value of <code>null</code> or <code>GL</code> will result in + * the default profile. + * + * @throws GLException if no implementation for the given profile is found. + */ + public static final GLProfile get(String profile) + throws GLException + { + if(null==profile || profile.equals("GL")) return getDefault(); + GLProfile glProfile = (GLProfile) mappedProfiles.get(profile); + if(null==glProfile) { + throw new GLException("No implementation for profile "+profile+" available"); + } + return glProfile; + } + /** * Returns the first profile from the given list, * where an implementation is available. @@ -191,18 +345,18 @@ public class GLProfile implements Cloneable { } private static final String getGLImplBaseClassName(String profileImpl) { - if(GL3bc.equals(profileImpl)) { - return "com.sun.opengl.impl.gl3.GL3bc"; - } else if(GL3.equals(profileImpl)) { - return "com.sun.opengl.impl.gl3.GL3"; - } else if(GL2.equals(profileImpl)) { - return "com.sun.opengl.impl.gl2.GL2"; + if ( GL4bc.equals(profileImpl) || + GL4.equals(profileImpl) || + GL3bc.equals(profileImpl) || + GL3.equals(profileImpl) || + GL2.equals(profileImpl) ) { + return "com.jogamp.opengl.impl.gl4.GL4bc"; } else if(GL2ES12.equals(profileImpl)) { - return "com.sun.opengl.impl.gl2es12.GL2ES12"; + return "com.jogamp.opengl.impl.gl2es12.GL2ES12"; } else if(GLES1.equals(profileImpl) || GL2ES1.equals(profileImpl)) { - return "com.sun.opengl.impl.es1.GLES1"; + return "com.jogamp.opengl.impl.es1.GLES1"; } else if(GLES2.equals(profileImpl) || GL2ES2.equals(profileImpl)) { - return "com.sun.opengl.impl.es2.GLES2"; + return "com.jogamp.opengl.impl.es2.GLES2"; } else { throw new GLException("unsupported profile \"" + profileImpl + "\""); } @@ -252,19 +406,29 @@ public class GLProfile implements Cloneable { return profileImpl; } + /** Indicates whether this profile is capable of GL4bc. */ + public final boolean isGL4bc() { + return GL4bc.equals(profile); + } + + /** Indicates whether this profile is capable of GL4. */ + public final boolean isGL4() { + return isGL4bc() || GL4.equals(profile); + } + /** Indicates whether this profile is capable of GL3bc. */ public final boolean isGL3bc() { - return GL3bc.equals(profile); + return isGL4bc() || GL3bc.equals(profile); } /** Indicates whether this profile is capable of GL3. */ public final boolean isGL3() { - return isGL3bc() || GL3.equals(profile); + return isGL4() || isGL3bc() || GL3.equals(profile); } - /** Indicates whether this profile is capable of GL2. */ + /** Indicates whether this context is a GL2 context */ public final boolean isGL2() { - return GL2.equals(profile); + return isGL3bc() || GL2.equals(profile); } /** Indicates whether this profile is capable of GLES1. */ @@ -292,6 +456,11 @@ public class GLProfile implements Cloneable { return GL2GL3.equals(profile) || isGL2() || isGL3() ; } + /** Indicates whether this profile supports GLSL. */ + public final boolean hasGLSL() { + return isGL2ES2() ; + } + /** Indicates whether this profile uses the native OpenGL ES1 implementations. */ public final boolean usesNativeGLES1() { return GLES1.equals(profileImpl); @@ -307,31 +476,6 @@ public class GLProfile implements Cloneable { return usesNativeGLES2() || usesNativeGLES1(); } - /** Indicates whether this profile uses the native desktop OpenGL GL2 implementations. */ - public final boolean usesNativeGL2() { - return GL2.equals(profileImpl) || GL2ES12.equals(profileImpl) ; - } - - /** Indicates whether this profile uses the native desktop OpenGL GL3bc implementations. */ - public final boolean usesNativeGL3bc() { - return GL3bc.equals(profileImpl); - } - - /** Indicates whether this profile uses the native desktop OpenGL GL3 implementations. */ - public final boolean usesNativeGL3() { - return usesNativeGL3bc() || GL3.equals(profileImpl); - } - - /** Indicates whether this profile uses the native desktop OpenGL GL2 or GL3 implementations. */ - public final boolean usesNativeGL2GL3() { - return usesNativeGL2() || usesNativeGL3() ; - } - - /** Indicates whether this profile supports GLSL. */ - public final boolean hasGLSL() { - return isGL2ES2() ; - } - /** * General validation if type is a valid GL data type * for the current profile @@ -639,18 +783,21 @@ public class GLProfile implements Cloneable { private static final boolean isAWTAvailable; private static final boolean isAWTJOGLAvailable; - private static final boolean hasGL3bcImpl; - private static final boolean hasGL3Impl; - private static final boolean hasGL2Impl; - private static final boolean hasGL2ES12Impl; - private static final boolean hasGLES2Impl; - private static final boolean hasGLES1Impl; + private static /*final*/ boolean hasGL234Impl; + private static /*final*/ boolean hasGL4bcImpl; + private static /*final*/ boolean hasGL4Impl; + private static /*final*/ boolean hasGL3bcImpl; + private static /*final*/ boolean hasGL3Impl; + private static /*final*/ boolean hasGL2Impl; + private static /*final*/ boolean hasGL2ES12Impl; + private static /*final*/ boolean hasGLES2Impl; + private static /*final*/ boolean hasGLES1Impl; /** The JVM/process wide default GL profile **/ - private static GLProfile defaultGLProfile; + private static /*final*/ GLProfile defaultGLProfile; /** All GLProfiles */ - private static final HashMap/*<String, GLProfile>*/ mappedProfiles; + private static /*final*/ HashMap/*<String, GLProfile>*/ mappedProfiles; /** * Tries the profiles implementation and native libraries. @@ -662,115 +809,203 @@ public class GLProfile implements Cloneable { AccessControlContext acc = AccessController.getContext(); isAWTAvailable = !Debug.getBooleanProperty("java.awt.headless", true, acc) && - NWReflection.isClassAvailable("java.awt.Component") ; + ReflectionUtil.isClassAvailable("java.awt.Component") ; isAWTJOGLAvailable = isAWTAvailable && - NWReflection.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow - NWReflection.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL + ReflectionUtil.isClassAvailable("javax.media.nativewindow.awt.AWTGraphicsDevice") && // NativeWindow + ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas") ; // JOGL boolean hasDesktopGL = false; boolean hasDesktopGLES12 = false; boolean hasNativeOSFactory = false; - + Throwable t; + + // + // First iteration of desktop GL availability detection + // - native libs exist + // - class exists + // + t=null; try { // See DRIHack.java for an explanation of why this is necessary DRIHack.begin(); - NativeLibLoader.loadGLDesktop(); + GLJNILibLoader.loadGLDesktop(); DRIHack.end(); hasDesktopGL = true; - } catch (Throwable t) { + } catch (UnsatisfiedLinkError ule) { + t=ule; + } catch (SecurityException se) { + t=se; + } catch (NullPointerException npe) { + t=npe; + } catch (RuntimeException re) { + t=re; + } + if(null!=t) { if (DEBUG) { System.err.println("GLProfile.static Desktop GL Library not available"); t.printStackTrace(); } } + t=null; try { // See DRIHack.java for an explanation of why this is necessary DRIHack.begin(); - NativeLibLoader.loadGLDesktopES12(); + GLJNILibLoader.loadGLDesktopES12(); DRIHack.end(); hasDesktopGLES12 = true; - } catch (Throwable t) { + } catch (UnsatisfiedLinkError ule) { + t=ule; + } catch (SecurityException se) { + t=se; + } catch (NullPointerException npe) { + t=npe; + } catch (RuntimeException re) { + t=re; + } + if(null!=t) { if (DEBUG) { - System.err.println("GLProfile.static Desktop GL ES12 Library not available"); + System.err.println("GLProfile.static Desktop GLES12 Library not available"); t.printStackTrace(); } } + + hasGL234Impl = hasDesktopGL && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl4.GL4bcImpl"); + hasGL4bcImpl = hasGL234Impl; + hasGL4Impl = hasGL234Impl; + hasGL3bcImpl = hasGL234Impl; + hasGL3Impl = hasGL234Impl; + hasGL2Impl = hasGL234Impl; + hasGL2ES12Impl = hasDesktopGLES12 && ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.gl2es12.GL2ES12Impl"); + mappedProfiles = computeProfileMap(); + + // + // Second iteration of desktop GL availability detection + // utilizing the detected GL version in the shared context. + // + // - Instantiate GLDrawableFactory incl its shared dummy drawable/context, + // which will register at GLContext .. + // + if(hasDesktopGL||hasDesktopGLES12) { + // if successfull it has a shared dummy drawable and context created try { - hasNativeOSFactory = null!=GLDrawableFactory.getFactoryImpl(GL2); - } catch (Throwable t) { - if (DEBUG) { - System.err.println("GLProfile.static - Native platform GLDrawable factory not available"); - t.printStackTrace(); - } + hasNativeOSFactory = null != GLDrawableFactory.getFactoryImpl(GL2); + } catch (RuntimeException re) { + System.err.println("GLProfile.static - Native platform GLDrawable factory not available"); + re.printStackTrace(); } } - if(!hasNativeOSFactory) { - hasDesktopGLES12=false; - hasDesktopGL=false; + if(hasNativeOSFactory && !GLContext.mappedVersionsAvailableSet) { + // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent}, + // so we have to add the usual suspect + GLContext.mapVersionAvailable(2, true, 1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY); } - // FIXME: check for real GL3 availability .. ? - hasGL3bcImpl = hasDesktopGL && NWReflection.isClassAvailable("com.sun.opengl.impl.gl3.GL3bcImpl"); - hasGL3Impl = hasDesktopGL && NWReflection.isClassAvailable("com.sun.opengl.impl.gl3.GL3Impl"); - hasGL2Impl = hasDesktopGL && NWReflection.isClassAvailable("com.sun.opengl.impl.gl2.GL2Impl"); - - hasGL2ES12Impl = hasDesktopGLES12 && NWReflection.isClassAvailable("com.sun.opengl.impl.gl2es12.GL2ES12Impl"); + if(!hasNativeOSFactory) { + hasDesktopGL = false; + hasGL234Impl = false; + hasGL4bcImpl = false; + hasGL4Impl = false; + hasGL3bcImpl = false; + hasGL3Impl = false; + hasGL2ES12Impl = false; + hasGL2Impl = false; + } else { + hasGL4bcImpl = hasGL4bcImpl && GLContext.isGL4bcAvailable(); + hasGL4Impl = hasGL4Impl && GLContext.isGL4Available(); + hasGL3bcImpl = hasGL3bcImpl && GLContext.isGL3bcAvailable(); + hasGL3Impl = hasGL3Impl && GLContext.isGL3Available(); + hasGL2Impl = hasGL2Impl && GLContext.isGL2Available(); + hasGL2ES12Impl = hasGL2ES12Impl && GLContext.isGL2Available(); + } boolean btest = false; - boolean hasEGLDynLookup = NWReflection.isClassAvailable("com.sun.opengl.impl.egl.EGLDynamicLookupHelper"); + boolean hasEGLDynLookup = ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper"); boolean hasEGLDrawableFactory = false; + t=null; try { if(hasEGLDynLookup) { hasEGLDrawableFactory = null!=GLDrawableFactory.getFactoryImpl(GLES2); - btest = hasEGLDrawableFactory && - NWReflection.isClassAvailable("com.sun.opengl.impl.es2.GLES2Impl") && - null!=com.sun.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2); + try { + btest = hasEGLDrawableFactory && + ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es2.GLES2Impl") && + null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(2); + } catch (GLException gle) { + // n/a .. + } } - } catch (Throwable t) { + } catch (UnsatisfiedLinkError ule) { + t=ule; + } catch (SecurityException se) { + t=se; + } catch (NullPointerException npe) { + t=npe; + } catch (RuntimeException re) { + t=re; + } + if(null!=t) { if (DEBUG) { System.err.println("GLProfile.static - GL ES2 Factory/Library not available"); t.printStackTrace(); } } hasGLES2Impl = btest; + if(hasGLES2Impl) { + GLContext.mapVersionAvailable(2, false, 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY); + } btest = false; - try { - if(hasEGLDynLookup) { + if(hasEGLDynLookup) { + try { btest = hasEGLDrawableFactory && - NWReflection.isClassAvailable("com.sun.opengl.impl.es1.GLES1Impl") && - null!=com.sun.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1); - } - } catch (Throwable t) { - if (DEBUG) { - System.err.println("GLProfile.static - GL ES1 Factory/Library not available"); - t.printStackTrace(); + ReflectionUtil.isClassAvailable("com.jogamp.opengl.impl.es1.GLES1Impl") && + null!=com.jogamp.opengl.impl.egl.EGLDynamicLookupHelper.getDynamicLookupHelper(1); + } catch (GLException jre) { + /* just not available .. */ } } hasGLES1Impl = btest; + if(hasGLES1Impl) { + GLContext.mapVersionAvailable(1, false, 1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_PROFILE_CORE|GLContext.CTX_OPTION_ANY); + } + + mappedProfiles = computeProfileMap(); + if(null==defaultGLProfile) { + throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL)+", "+glAvailabilityToString()); + } if (DEBUG) { System.err.println("GLProfile.static isAWTAvailable "+isAWTAvailable); System.err.println("GLProfile.static isAWTJOGLAvailable "+isAWTJOGLAvailable); System.err.println("GLProfile.static hasNativeOSFactory "+hasNativeOSFactory); - System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12); System.err.println("GLProfile.static hasDesktopGL "+hasDesktopGL); - System.err.println("GLProfile.static hasGL3bcImpl "+hasGL3bcImpl); - System.err.println("GLProfile.static hasGL3Impl "+hasGL3Impl); - System.err.println("GLProfile.static hasGL2Impl "+hasGL2Impl); - System.err.println("GLProfile.static hasGL2ES12Impl "+hasGL2ES12Impl); + System.err.println("GLProfile.static hasDesktopGLES12 "+hasDesktopGLES12); System.err.println("GLProfile.static hasEGLDynLookup "+hasEGLDynLookup); System.err.println("GLProfile.static hasEGLDrawableFactory "+hasEGLDrawableFactory); - System.err.println("GLProfile.static hasGLES2Impl "+hasGLES2Impl); - System.err.println("GLProfile.static hasGLES1Impl "+hasGLES1Impl); + System.err.println("GLProfile.static hasGL234Impl "+hasGL234Impl); + System.err.println("GLProfile.static "+glAvailabilityToString()); } + } + private static final String list2String(String[] list) { + StringBuffer msg = new StringBuffer(); + msg.append("["); + for (int i = 0; i < list.length; i++) { + if (i > 0) + msg.append(", "); + msg.append(list[i]); + } + msg.append("]"); + return msg.toString(); + } + + private static HashMap computeProfileMap() { + defaultGLProfile=null; HashMap/*<String, GLProfile>*/ _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length); for(int i=0; i<GL_PROFILE_LIST_ALL.length; i++) { String profile = GL_PROFILE_LIST_ALL[i]; @@ -793,22 +1028,7 @@ public class GLProfile implements Cloneable { } } } - mappedProfiles = _mappedProfiles; // final .. - if(null==defaultGLProfile) { - throw new GLException("No profile available: "+list2String(GL_PROFILE_LIST_ALL)); - } - } - - private static final String list2String(String[] list) { - StringBuffer msg = new StringBuffer(); - msg.append("["); - for (int i = 0; i < list.length; i++) { - if (i > 0) - msg.append(", "); - msg.append(list[i]); - } - msg.append("]"); - return msg.toString(); + return _mappedProfiles; } /** @@ -820,6 +1040,10 @@ public class GLProfile implements Cloneable { return GL2ES12; } else if(hasGL2Impl) { return GL2; + } else if(hasGL3bcImpl) { + return GL3bc; + } else if(hasGL4bcImpl) { + return GL4bc; } else if(hasGLES1Impl) { return GLES1; } @@ -830,23 +1054,33 @@ public class GLProfile implements Cloneable { return GL2; } else if(hasGL3Impl) { return GL3; - } else if(hasGL3bcImpl) { - return GL3bc; + } else if(hasGL4Impl) { + return GL4; } else if(hasGLES2Impl) { return GLES2; } - } else if(GL3bc.equals(profile) && hasGL3bcImpl) { - return GL3bc; - } else if(GL3.equals(profile)) { - if(hasGL3Impl) { - return GL3; + } else if(GL2GL3.equals(profile)) { + if(hasGL2Impl) { + return GL2; } else if(hasGL3bcImpl) { return GL3bc; + } else if(hasGL4bcImpl) { + return GL4bc; + } else if(hasGL3Impl) { + return GL3; + } else if(hasGL4Impl) { + return GL4; } + } else if(GL4bc.equals(profile) && hasGL4bcImpl) { + return GL4bc; + } else if(GL4.equals(profile) && hasGL4Impl) { + return GL4; + } else if(GL3bc.equals(profile) && hasGL3bcImpl) { + return GL3bc; + } else if(GL3.equals(profile) && hasGL3Impl) { + return GL3; } else if(GL2.equals(profile) && hasGL2Impl) { return GL2; - } else if(GL2GL3.equals(profile) && hasGL2Impl) { - return GL2; } else if(GLES2.equals(profile) && hasGLES2Impl) { return GLES2; } else if(GLES1.equals(profile) && hasGLES1Impl) { diff --git a/src/jogl/classes/javax/media/opengl/GLUniformData.java b/src/jogl/classes/javax/media/opengl/GLUniformData.java index f628ce35a..9b0d5f151 100644 --- a/src/jogl/classes/javax/media/opengl/GLUniformData.java +++ b/src/jogl/classes/javax/media/opengl/GLUniformData.java @@ -10,7 +10,6 @@ public class GLUniformData { * * Number of objects is 1 * - * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4, */ public GLUniformData(String name, int val) { init(name, 1, new Integer(val)); @@ -21,7 +20,6 @@ public class GLUniformData { * * Number of objects is 1 * - * @param components number of elements of one object, ie 4 for GL_FLOAT_VEC4, */ public GLUniformData(String name, float val) { init(name, 1, new Float(val)); diff --git a/src/jogl/classes/javax/media/opengl/Threading.java b/src/jogl/classes/javax/media/opengl/Threading.java index fecf6c78b..e58792b8f 100755 --- a/src/jogl/classes/javax/media/opengl/Threading.java +++ b/src/jogl/classes/javax/media/opengl/Threading.java @@ -39,7 +39,7 @@ package javax.media.opengl; -import com.sun.opengl.impl.*; +import com.jogamp.opengl.impl.*; /** This API provides access to the threading model for the implementation of the classes in this package. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 038d6d280..53e79b8d9 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -43,7 +43,7 @@ import javax.media.opengl.*; import javax.media.nativewindow.*; import javax.media.nativewindow.awt.*; -import com.sun.opengl.impl.*; +import com.jogamp.opengl.impl.*; import java.awt.Canvas; import java.awt.Color; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index e4758211e..e8de00629 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -41,20 +41,17 @@ package javax.media.opengl.awt; import javax.media.opengl.*; import javax.media.nativewindow.*; -import javax.media.nativewindow.awt.*; import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.beans.*; -import javax.swing.*; import java.nio.*; import java.security.*; -import javax.swing.JComponent; import javax.swing.JPanel; -import com.sun.opengl.util.FBObject; -import com.sun.opengl.impl.*; -import com.sun.opengl.impl.awt.*; +import com.jogamp.opengl.util.FBObject; +import com.jogamp.opengl.impl.*; +import com.jogamp.opengl.impl.awt.*; // FIXME: Subclasses need to call resetGLFunctionAvailability() on their // context whenever the displayChanged() function is called on their @@ -497,7 +494,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { backend = new J2DOGLBackend(); } else { if (!hardwareAccelerationDisabled && - factory.canCreateGLPbuffer()) { + factory.canCreateGLPbuffer(null)) { backend = new PbufferBackend(); } else { if (softwareRenderingDisabled) { @@ -1429,7 +1426,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { System.err.println("-- Created External Context: "+j2dContext); } if (DEBUG) { - j2dContext.setGL(new DebugGL2(j2dContext.getGL().getGL2())); +// j2dContext.setGL(new DebugGL2(j2dContext.getGL().getGL2())); } // Check to see whether we can support the requested @@ -1512,7 +1509,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { } } if (joglContext == null) { - if (factory.canCreateExternalGLDrawable()) { + AbstractGraphicsDevice device = j2dContext.getGLDrawable().getNativeWindow().getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice(); + if (factory.canCreateExternalGLDrawable(device)) { joglDrawable = factory.createExternalGLDrawable(); // FIXME: Need to share with j2d context, due to FBO resource .. // - ORIG: joglContext = joglDrawable.createContext(shareWith); @@ -1521,7 +1519,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable { System.err.println("-- Created External Drawable: "+joglDrawable); System.err.println("-- Created Context: "+joglContext); } - } else if (factory.canCreateContextOnJava2DSurface()) { + } else if (factory.canCreateContextOnJava2DSurface(device)) { // Mac OS X code path // FIXME: Need to share with j2d context, due to FBO resource .. // - ORIG: joglContext = factory.createContextOnJava2DSurface(g, shareWith); diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java index 61757abde..b899f3c0a 100644 --- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java +++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java @@ -6,8 +6,6 @@ package javax.media.opengl.fixedfunc; import java.nio.*; -import javax.media.opengl.*; - public interface GLMatrixFunc { public static final int GL_MATRIX_MODE = 0x0BA0; @@ -56,7 +54,7 @@ public interface GLMatrixFunc { /** * glMultMatrixf - * @param params the FloatBuffer's position remains unchanged, + * @param m the FloatBuffer's position remains unchanged, * which is the same behavior than the native JOGL GL impl */ public void glMultMatrixf(java.nio.FloatBuffer m) ; diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java b/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java index d5a7a11f3..49451a34b 100755 --- a/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java +++ b/src/jogl/classes/javax/media/opengl/glu/GLUquadric.java @@ -1,7 +1,7 @@ package javax.media.opengl.glu; import javax.media.opengl.GL; -import com.sun.opengl.util.ImmModeSink; +import com.jogamp.opengl.util.ImmModeSink; /** * Wrapper for a GLU quadric object. diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java index cb7bd9d76..f98bbe158 100755 --- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java +++ b/src/jogl/classes/javax/media/opengl/glu/GLUtessellator.java @@ -6,7 +6,7 @@ /* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this +** Software License B, Version 2.0 (the "License"), the contents of this ** file are subject only to the provisions of the License. You may not use ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java index 4b5ec63b7..72ad68ceb 100755 --- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java +++ b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallback.java @@ -6,7 +6,7 @@ /* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this +** Software License B, Version 2.0 (the "License"), the contents of this ** file are subject only to the provisions of the License. You may not use ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 @@ -352,5 +352,5 @@ public interface GLUtessellatorCallback { */ public void errorData(int errnum, Object polygonData); - //void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh); + //void mesh(com.jogamp.opengl.impl.tessellator.GLUmesh mesh); } diff --git a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java index bf6f2d29a..f380f4698 100755 --- a/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java +++ b/src/jogl/classes/javax/media/opengl/glu/GLUtessellatorCallbackAdapter.java @@ -6,7 +6,7 @@ /* ** License Applicability. Except to the extent portions of this file are ** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this +** Software License B, Version 2.0 (the "License"), the contents of this ** file are subject only to the provisions of the License. You may not use ** this file except in compliance with the License. You may obtain a copy ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 @@ -68,7 +68,7 @@ public class GLUtessellatorCallbackAdapter implements GLUtessellatorCallback { public void edgeFlag(boolean boundaryEdge) {} public void vertex(Object vertexData) {} public void end() {} -// public void mesh(com.sun.opengl.impl.tessellator.GLUmesh mesh) {} +// public void mesh(com.jogamp.opengl.impl.tessellator.GLUmesh mesh) {} public void error(int errnum) {} public void combine(double[] coords, Object[] data, float[] weight, Object[] outData) {} |