aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/JoglVersion.java50
-rw-r--r--src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java12
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java3
-rw-r--r--src/jogl/classes/com/jogamp/openmax/OMXInstance.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/GLBase.java71
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java156
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java217
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java11
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java62
-rw-r--r--src/jogl/classes/jogamp/opengl/awt/Java2D.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java106
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java82
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java27
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java9
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java6
22 files changed, 585 insertions, 298 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
index 5172cccbd..bf7eb0770 100644
--- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
+++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
@@ -34,6 +34,8 @@ import javax.media.opengl.*;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.common.util.JogampVersion;
+
+import java.util.List;
import java.util.jar.Manifest;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -68,6 +70,46 @@ public class JoglVersion extends JogampVersion {
return toString(gl, null).toString();
}
+ public static StringBuilder getAvailableCapabilitiesInfo(GLDrawableFactory factory, AbstractGraphicsDevice device, StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ boolean done = false;
+ if(null!=factory) {
+ try {
+ final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(device);
+ for(int i=0; i<availCaps.size(); i++) {
+ sb.append("\t").append(availCaps.get(i)).append(Platform.getNewline());
+ }
+ done = true;
+ } catch (GLException gle) { /* n/a */ }
+ }
+ if(!done) {
+ sb.append("\tnone").append(Platform.getNewline());
+ }
+ sb.append(Platform.getNewline());
+ return sb;
+ }
+
+ public static StringBuilder getDefaultOpenGLInfo(StringBuilder sb) {
+ if(null==sb) {
+ sb = new StringBuilder();
+ }
+ final AbstractGraphicsDevice device = GLProfile.getDefaultDevice();
+ sb.append("Default Profiles ").append(Platform.getNewline());
+ if(null!=device) {
+ GLProfile.glAvailabilityToString(device, sb, "\t", 1);
+ } else {
+ sb.append("none");
+ }
+ sb.append(Platform.getNewline()).append(Platform.getNewline());
+ sb.append("Desktop Capabilities: ").append(Platform.getNewline());
+ getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb);
+ sb.append("EGL Capabilities: ").append(Platform.getNewline());
+ getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb);
+ return sb;
+ }
+
public static StringBuilder getGLInfo(GL gl, StringBuilder sb) {
AbstractGraphicsDevice device = gl.getContext().getGLDrawable().getNativeSurface()
.getGraphicsConfiguration().getScreen().getDevice();
@@ -78,8 +120,8 @@ public class JoglVersion extends JogampVersion {
sb.append(VersionUtil.SEPERATOR).append(Platform.getNewline());
sb.append(device.getClass().getSimpleName()).append("[type ")
- .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ")
- .append(GLProfile.glAvailabilityToString(device));
+ .append(device.getType()).append(", connection ").append(device.getConnection()).append("]: ").append(Platform.getNewline());
+ GLProfile.glAvailabilityToString(device, sb, "\t", 1);
sb.append(Platform.getNewline());
sb.append("Swap Interval ").append(gl.getSwapInterval());
sb.append(Platform.getNewline());
@@ -91,7 +133,7 @@ public class JoglVersion extends JogampVersion {
sb.append(Platform.getNewline());
sb.append("GL_VENDOR ").append(gl.glGetString(GL.GL_VENDOR));
sb.append(Platform.getNewline());
- sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER));
+ sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER));
sb.append(Platform.getNewline());
sb.append("GL_VERSION ").append(gl.glGetString(GL.GL_VERSION));
sb.append(Platform.getNewline());
@@ -99,7 +141,7 @@ public class JoglVersion extends JogampVersion {
sb.append(Platform.getNewline());
sb.append(" ").append(ctx.getGLExtensionsString());
sb.append(Platform.getNewline());
- sb.append("GLX_EXTENSIONS ");
+ sb.append("GLX_EXTENSIONS");
sb.append(Platform.getNewline());
sb.append(" ").append(ctx.getPlatformExtensionsString());
sb.append(Platform.getNewline());
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index c982ce16d..91f79793c 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -27,8 +27,6 @@
*/
package com.jogamp.opengl.swt;
-import java.util.List;
-
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.ProxySurface;
@@ -538,13 +536,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
// System.err.println(NativeWindowVersion.getInstance());
System.err.println(JoglVersion.getInstance());
- final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
- final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null);
- for(int i=0; i<availCaps.size(); i++) {
- System.err.println(availCaps.get(i));
- }
-
- final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDesktopDevice()) );
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(null).toString());
+
+ final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) );
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setSize(128,128);
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
index 747dd5c49..1f200bf3b 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java
@@ -188,7 +188,7 @@ public class ShaderUtil {
int[] param = new int[1];
shaderBinaryFormats = new HashSet<Integer>();
- if (gl.isGLES2()) {
+ if (gl.isGLES2Compatible()) {
gl.glGetIntegerv(GL2ES2.GL_NUM_SHADER_BINARY_FORMATS, param, 0);
int numFormats = param[0];
if(numFormats>0) {
@@ -329,7 +329,6 @@ public class ShaderUtil {
throw new GLException("createAndLoadShader: CreateShader failed, GL Error: 0x"+Integer.toHexString(err));
}
-
shaderBinary(gl, shader, binFormat, bin);
err = gl.glGetError();
diff --git a/src/jogl/classes/com/jogamp/openmax/OMXInstance.java b/src/jogl/classes/com/jogamp/openmax/OMXInstance.java
index fcd055f8b..7c373a0ef 100644
--- a/src/jogl/classes/com/jogamp/openmax/OMXInstance.java
+++ b/src/jogl/classes/com/jogamp/openmax/OMXInstance.java
@@ -472,7 +472,7 @@ public class OMXInstance {
private void errorCheckEGL(String s) {
int e;
if( (e=EGL.eglGetError()) != EGL.EGL_SUCCESS ) {
- System.out.println("EGL Error: ("+s+"): "+e);
+ System.out.println("EGL Error: ("+s+"): 0x"+Integer.toHexString(e));
}
}
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index 899503ea6..bd24b15bc 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -81,86 +81,80 @@ package javax.media.opengl;
public interface GLBase {
/**
- * Indicates whether this GL object conforms to any of the common GL profiles.
- * @return whether this GL object conforms to any of the common GL profiles
+ * Indicates whether this GL object conforms to any of the OpenGL profiles.
*/
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
+ * Indicates whether this GL object conforms to the OpenGL &ge; 4.0 compatibility profile.
+ * The GL4 compatibility profile includes the GL2, GL2ES1, GL2ES2, GL3, GL3bc and GL4 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
+ * Indicates whether this GL object conforms to the OpenGL &ge; 4.0 core profile.
+ * The GL4 core profile includes the GL2ES2, and GL3 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
+ * Indicates whether this GL object conforms to the OpenGL &ge; 3.1 compatibility profile.
+ * The GL3 compatibility profile includes the GL2, GL2ES1, GL2ES2 and GL3 profile.
*/
public boolean isGL3bc();
/**
- * Indicates whether this GL object conforms to the GL3 core profile.
- * The GL3 core profile reflects OpenGL versions greater or equal 3.1
- * @return whether this GL object conforms to the GL3 core profile
+ * Indicates whether this GL object conforms to the OpenGL &ge; 3.1 core profile.
+ * The GL3 core profile includes the GL2ES2 profile.
*/
public boolean isGL3();
/**
- * Indicates whether this GL object conforms to the GL2 profile.
- * The GL2 profile reflects OpenGL versions greater or equal 1.5
- * @return whether this GL object conforms to the GL2 profile
+ * Indicates whether this GL object conforms to the OpenGL &le; 3.0 profile.
+ * The GL2 profile includes the GL2ES1 and GL2ES2 profile.
*/
public boolean isGL2();
/**
- * Indicates whether this GL object conforms to the GLES1 profile.
- * @return whether this GL object conforms to the GLES1 profile
+ * Indicates whether this GL object conforms to the OpenGL ES1 &ge; 1.0 profile.
*/
public boolean isGLES1();
/**
- * Indicates whether this GL object conforms to the GLES2 profile.
- * @return whether this GL object conforms to the GLES2 profile
+ * Indicates whether this GL object conforms to the OpenGL ES2 &ge; 2.0 profile.
+ * <p>
+ * Remark: ES2 compatible desktop profiles are not included.
+ * To query whether core ES2 functionality is provided, use {@link #isGLES2Compatible()}.
+ * </p>
+ * @see #isGLES2Compatible()
*/
public boolean isGLES2();
/**
- * Indicates whether this GL object conforms to one of the OpenGL ES compatible profiles.
- * @return whether this GL object conforms to one of the OpenGL ES profiles
+ * Indicates whether this GL object conforms to one of the OpenGL ES profiles,
+ * see {@link #isGLES1()} and {@link #isGLES2()}.
*/
public boolean isGLES();
/**
- * Indicates whether this GL object conforms to the GL2ES1 compatible profile.
- * @return whether this GL object conforms to the GL2ES1 profile
+ * Indicates whether this GL object conforms to a GL2ES1 compatible profile.
*/
public boolean isGL2ES1();
/**
- * Indicates whether this GL object conforms to the GL2ES2 compatible profile.
- * @return whether this GL object conforms to the GL2ES2 profile
+ * Indicates whether this GL object conforms to a GL2ES2 compatible profile.
*/
public boolean isGL2ES2();
/**
- * Indicates whether this GL object is compatible with OpenGL ES2.
+ * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality.
* @return true if this context is an ES2 context or implements
* the extension <code>GL_ARB_ES2_compatibility</code>, otherwise false
*/
public boolean isGLES2Compatible();
/**
- * Indicates whether this GL object conforms to the GL2GL3 compatible profile.
- * @return whether this GL object conforms to the GL2GL3 profile
+ * Indicates whether this GL object conforms to a GL2GL3 compatible profile.
*/
public boolean isGL2GL3();
@@ -169,90 +163,77 @@ public interface GLBase {
/**
* Casts this object to the GL interface.
- * @return this object cast to the GL interface
* @throws GLException if this GLObject is not a GL implementation
*/
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
*/
public GL3bc getGL3bc() throws GLException;
/**
* Casts this object to the GL3 interface.
- * @return this object cast to the GL3 interface
* @throws GLException if this GLObject is not a GL3 implementation
*/
public GL3 getGL3() throws GLException;
/**
* Casts this object to the GL2 interface.
- * @return this object cast to the GL2 interface
* @throws GLException if this GLObject is not a GL2 implementation
*/
public GL2 getGL2() throws GLException;
/**
* Casts this object to the GLES1 interface.
- * @return this object cast to the GLES1 interface
* @throws GLException if this GLObject is not a GLES1 implementation
*/
public GLES1 getGLES1() throws GLException;
/**
* Casts this object to the GLES2 interface.
- * @return this object cast to the GLES2 interface
* @throws GLException if this GLObject is not a GLES2 implementation
*/
public GLES2 getGLES2() throws GLException;
/**
* Casts this object to the GL2ES1 interface.
- * @return this object cast to the GL2ES1 interface
* @throws GLException if this GLObject is not a GL2ES1 implementation
*/
public GL2ES1 getGL2ES1() throws GLException;
/**
* Casts this object to the GL2ES2 interface.
- * @return this object cast to the GL2ES2 interface
* @throws GLException if this GLObject is not a GL2ES2 implementation
*/
public GL2ES2 getGL2ES2() throws GLException;
/**
* Casts this object to the GL2GL3 interface.
- * @return this object cast to the GL2GL3 interface
* @throws GLException if this GLObject is not a GL2GL3 implementation
*/
public GL2GL3 getGL2GL3() throws GLException;
/**
- * Returns the GLProfile with which this GL object is associated.
- * @return the GLProfile with which this GL object is associated
+ * Returns the GLProfile associated with this GL object.
*/
public GLProfile getGLProfile();
/**
- * Returns the GLContext with which this GL object is associated.
- * @return the GLContext with which this GL object is associated
+ * Returns the GLContext associated which this GL object.
*/
public GLContext getContext();
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 131f42e06..0cf92fb14 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -91,26 +91,26 @@ public abstract class GLContext {
public static final int CONTEXT_CURRENT_NEW = 2;
/** <code>ARB_create_context</code> related: created via ARB_create_context */
- protected static final int CTX_IS_ARB_CREATED = 1 << 0;
+ 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;
+ 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;
+ protected static final int CTX_PROFILE_CORE = 1 << 2;
/** <code>ARB_create_context</code> related: ES profile */
- protected static final int CTX_PROFILE_ES = 1 << 3;
+ 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;
+ protected static final int CTX_OPTION_FORWARD = 1 << 4;
/** <code>ARB_create_context</code> related: flag not forward compatible */
- protected static final int CTX_OPTION_ANY = 1 << 5;
+ protected static final int CTX_OPTION_ANY = 1 << 5;
/** <code>ARB_create_context</code> related: flag debug */
- public static final int CTX_OPTION_DEBUG = 1 << 6;
- /** <code>GL_ARB_ES2_compatibility</code> related: Context is compatible w/ ES2 */
- protected static final int CTX_PROFILE_ES2_COMPAT = 1 << 8;
-
- /** GLContext {@link com.jogamp.gluegen.runtime.ProcAddressTable} caching related: GL software implementation */
- protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 0;
- /** GLContext {@link com.jogamp.gluegen.runtime.ProcAddressTable} caching related: GL hardware implementation */
- protected static final int CTX_IMPL_ACCEL_HARD = 1 << 1;
+ public static final int CTX_OPTION_DEBUG = 1 << 6;
+ /** <code>GL_ARB_ES2_compatibility</code> implementation related: Context is compatible w/ ES2 */
+ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8;
+
+ /** Implementation / GLContext {@link com.jogamp.gluegen.runtime.ProcAddressTable} caching related: GL software implementation */
+ protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 14;
+ /** Implementation / GLContext {@link com.jogamp.gluegen.runtime.ProcAddressTable} caching related: GL hardware implementation */
+ protected static final int CTX_IMPL_ACCEL_HARD = 1 << 15;
private static ThreadLocal<GLContext> currentContext = new ThreadLocal<GLContext>();
@@ -471,13 +471,17 @@ public abstract class GLContext {
* <ul>
* <li> options
* <ul>
+ * <li> <code>ES profile</code> ES profile</li>
+ * <li> <code>Compatibility profile</code>Compatibility profile including fixed function pipeline and deprecated functionality</li>
+ * <li> <code>Core profile</code>Core profile</li>
+ * <li> <code>forward</code>Forward profile excluding deprecated functionality</li>
+ * <li> <code>any</code> refers to the non forward compatible context</li>
* <li> <code>old</code> refers to the non ARB_create_context created context</li>
* <li> <code>new</code> refers to the ARB_create_context created context</li>
- * <li> <code>compatible profile</code></li>
- * <li> <code>core profile</code></li>
- * <li> <code>forward compatible</code></li>
- * <li> <code>any</code> refers to the non forward compatible context</li>
- * <li> <code>ES</code> refers to the GLES context variant</li>
+ * <li> <code>debug</code> refers to a debug context</li>
+ * <li> <code>ES2 compatible</code> refers to an ES2 compatible implementation</li>
+ * <li> <code>software</code> refers to a software implementation of the rasterizer</li>
+ * <li> <code>hardware</code> refers to a hardware implementation of the rasterizer</li>
* </ul></li>
* <li> <i>gl-version</i> the GL_VERSION string</li>
* </ul>
@@ -492,13 +496,14 @@ public abstract class GLContext {
* </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>
+ * <tr><td></td> <td>ES2</td> <td><code>2.0 (ES profile, any, new, ES2 compatible, hardware) - 2.0 ES Profile</code></td></tr>
+ * <tr><td>ATI</td><td>GL2</td> <td><code>3.0 (Compatibility profile, any, new, hardware) - 3.2.9704 Compatibility Profile Context</code></td></tr>
+ * <tr><td>ATI</td><td>GL3</td> <td><code>3.3 (Core profile, any, new, hardware) - 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, hardware) - 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, hardware) - 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, hardware) - 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, hardware) - 3.3.0 NVIDIA 195.36.07.03</code></td></tr>
+ * <tr><td>NV</td><td>GL2</td> <td><code>3.0 (Compatibility profile, any, new, ES2 compatible, hardware) - 3.0.0 NVIDIA 290.10</code></td></tr>
* </table>
*/
public final String getGLVersion() {
@@ -560,7 +565,7 @@ public abstract class GLContext {
* the extension <code>GL_ARB_ES2_compatibility</code>, otherwise false
*/
public final boolean isGLES2Compatible() {
- return 0 != ( ctxOptions & CTX_PROFILE_ES2_COMPAT ) ;
+ return 0 != ( ctxOptions & CTX_IMPL_ES2_COMPAT ) ;
}
public final boolean hasGLSL() {
@@ -742,29 +747,10 @@ public abstract class GLContext {
return true;
}
- 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 int composeBits(int a8, int b8, int c16) {
+ return ( ( a8 & 0x000000FF ) << 24 ) |
+ ( ( b8 & 0x000000FF ) << 16 ) |
+ ( ( c16 & 0x0000FFFF ) ) ;
}
private static void validateProfileBits(int bits, String argName) {
@@ -792,7 +778,7 @@ public abstract class GLContext {
private static /*final*/ HashSet<String> deviceVersionsAvailableSet = new HashSet<String>();
protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) {
- return device.getUniqueID() + "-" + toHexString(compose8bit(major, profile, 0, 0));
+ return device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0));
}
protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) {
@@ -841,7 +827,7 @@ public abstract class GLContext {
validateProfileBits(resCtp, "resCtp");
String key = getDeviceVersionAvailableKey(device, reqMajor, profile);
- Integer val = new Integer(compose8bit(resMajor, resMinor, resCtp, 0));
+ Integer val = new Integer(composeBits(resMajor, resMinor, resCtp));
synchronized(deviceVersionAvailable) {
val = deviceVersionAvailable.put( key, val );
}
@@ -872,20 +858,57 @@ public abstract class GLContext {
return false;
}
- int val = valI.intValue();
+ int bits32 = valI.intValue();
if(null!=major) {
- major[0] = getComposed8bit(val, 1);
+ major[0] = ( bits32 & 0xFF000000 ) >> 24 ;
}
if(null!=minor) {
- minor[0] = getComposed8bit(val, 2);
+ minor[0] = ( bits32 & 0x00FF0000 ) >> 16 ;
}
if(null!=ctp) {
- ctp[0] = getComposed8bit(val, 3);
+ ctp[0] = ( bits32 & 0x0000FFFF ) ;
}
return true;
}
+ /**
+ * returns the highest GLProfile string regarding the implementation version and context profile bits.
+ * @throws GLException if version and context profile bits could not be mapped to a GLProfile
+ */
+ protected static String getGLProfile(int major, int minor, int ctp)
+ throws GLException {
+ if(0 != ( CTX_PROFILE_COMPAT & ctp )) {
+ if(major >= 4) { return GLProfile.GL4bc; }
+ else if(major == 3 && minor >= 1) { return GLProfile.GL3bc; }
+ else { return GLProfile.GL2; }
+ } else if(0 != ( CTX_PROFILE_CORE & ctp )) {
+ if(major >= 4) { return GLProfile.GL4; }
+ else if(major == 3 && minor >= 1) { return GLProfile.GL3; }
+ } else if(0 != ( CTX_PROFILE_ES & ctp )) {
+ if(major == 2) { return GLProfile.GLES2; }
+ else if(major == 1) { return GLProfile.GLES1; }
+ }
+ throw new GLException("Unhandled OpenGL version/profile: "+GLContext.getGLVersion(major, minor, ctp, null));
+ }
+
+ /**
+ * @param major Key Value either 1, 2, 3 or 4
+ * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
+ * @return the highest GLProfile string regarding the version and profile bits.
+ * @throws GLException if version and context profile bits could not be mapped to a GLProfile
+ */
+ public static String getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile)
+ throws GLException {
+ int major[] = { 0 };
+ int minor[] = { 0 };
+ int ctp[] = { 0 };
+ if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) {
+ return GLContext.getGLProfile(major[0], minor[0], ctp[0]);
+ }
+ return null;
+ }
+
/**
* @param major Key Value either 1, 2, 3 or 4
* @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES}
@@ -943,15 +966,17 @@ public abstract class GLContext {
sb.append(".");
sb.append(minor);
sb.append(" (");
- needColon = appendString(sb, "ES", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
- needColon = appendString(sb, "ES2 compatible", needColon, 0 != ( CTX_PROFILE_ES2_COMPAT & ctp ));
- needColon = appendString(sb, "compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
- needColon = appendString(sb, "core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
- needColon = appendString(sb, "forward compatible", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
- needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp ));
+ needColon = appendString(sb, "ES profile", needColon, 0 != ( CTX_PROFILE_ES & ctp ));
+ needColon = appendString(sb, "Compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp ));
+ needColon = appendString(sb, "Core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp ));
+ needColon = appendString(sb, "forward", needColon, 0 != ( CTX_OPTION_FORWARD & ctp ));
needColon = appendString(sb, "any", needColon, 0 != ( CTX_OPTION_ANY & ctp ));
needColon = appendString(sb, "new", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp ));
needColon = appendString(sb, "old", needColon, 0 == ( CTX_IS_ARB_CREATED & ctp ));
+ needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp ));
+ needColon = appendString(sb, "ES2 compatible", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp ));
+ needColon = appendString(sb, "software", needColon, 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ));
+ needColon = appendString(sb, "hardware", needColon, 0 != ( CTX_IMPL_ACCEL_HARD & ctp ));
sb.append(")");
if(null!=gl_version) {
sb.append(" - ");
@@ -964,13 +989,6 @@ public abstract class GLContext {
// internal string utils
//
- 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);
}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 3f9700436..088ff054a 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -317,15 +317,13 @@ public abstract class GLDrawableFactory {
protected static GLDrawableFactory getFactoryImpl(String glProfileImplName) throws GLException {
if ( GLProfile.usesNativeGLES(glProfileImplName) ) {
- if(null==eglFactory) {
- throw new GLException("No EGLDrawableFactory available for profile: "+glProfileImplName);
+ if(null!=eglFactory) {
+ return eglFactory;
}
- return eglFactory;
- }
- if(null==nativeOSFactory) {
- throw new GLException("No native platform GLDrawableFactory available for profile: "+glProfileImplName);
+ } else if(null!=nativeOSFactory) {
+ return nativeOSFactory;
}
- return nativeOSFactory;
+ throw new GLException("No GLDrawableFactory available for profile: "+glProfileImplName);
}
protected static GLDrawableFactory getFactoryImpl(AbstractGraphicsDevice device) throws GLException {
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 6b39fe765..91dcd4e27 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -39,7 +39,6 @@ package javax.media.opengl;
import jogamp.opengl.Debug;
import jogamp.opengl.GLDrawableFactoryImpl;
-import jogamp.opengl.GLDynamicLookupHelper;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
import com.jogamp.common.GlueGenVersion;
@@ -246,8 +245,25 @@ public class GLProfile {
}
public static String glAvailabilityToString(AbstractGraphicsDevice device) {
+ return glAvailabilityToString(device, null).toString();
+ }
+
+ public static StringBuilder glAvailabilityToString(AbstractGraphicsDevice device, StringBuilder sb) {
+ return glAvailabilityToString(device, sb, null, 0);
+ }
+ private static StringBuilder doIndent(StringBuilder sb, String indent, int indentCount) {
+ while(indentCount>0) {
+ sb.append(indent);
+ indentCount--;
+ }
+ return sb;
+ }
+ public static StringBuilder glAvailabilityToString(AbstractGraphicsDevice device, StringBuilder sb, String indent, int indentCount) {
boolean avail;
- StringBuffer sb = new StringBuffer();
+ if(null == sb) {
+ sb = new StringBuilder();
+ }
+ final boolean useIndent = null != indent;
initSingleton();
@@ -256,77 +272,135 @@ public class GLProfile {
}
final HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device, false);
- sb.append("GLAvailability[Native[GL4bc ");
+ if(useIndent) {
+ doIndent(sb, indent, indentCount).append("Native");
+ indentCount++;
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4bc").append(indent);
+ } else {
+ sb.append("Native[GL4bc ");
+ }
avail=isAvailableImpl(map, GL4bc);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 4, GLContext.CTX_PROFILE_COMPAT);
+ glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_COMPAT);
}
- sb.append(", GL4 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4").append(indent);
+ } else {
+ sb.append(", GL4 ");
+ }
avail=isAvailableImpl(map, GL4);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 4, GLContext.CTX_PROFILE_CORE);
+ glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE);
}
- sb.append(", GL3bc ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent);
+ } else {
+ sb.append(", GL3bc ");
+ }
avail=isAvailableImpl(map, GL3bc);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 3, GLContext.CTX_PROFILE_COMPAT);
+ glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_COMPAT);
}
- sb.append(", GL3 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3").append(indent);
+ } else {
+ sb.append(", GL3 ");
+ }
avail=isAvailableImpl(map, GL3);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 3, GLContext.CTX_PROFILE_CORE);
+ glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_CORE);
}
- sb.append(", GL2 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2").append(indent);
+ } else {
+ sb.append(", GL2 ");
+ }
avail=isAvailableImpl(map, GL2);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 2, GLContext.CTX_PROFILE_COMPAT);
+ glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT);
}
- sb.append(", GL2ES1 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent);
+ } else {
+ sb.append(", GL2ES1 ");
+ }
sb.append(isAvailableImpl(map, GL2ES1));
- sb.append(", GLES1 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent);
+ } else {
+ sb.append(", GLES1 ");
+ }
avail=isAvailableImpl(map, GLES1);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 1, GLContext.CTX_PROFILE_ES);
+ glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES);
}
- sb.append(", GL2ES2 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent);
+ } else {
+ sb.append(", GL2ES2 ");
+ }
sb.append(isAvailableImpl(map, GL2ES2));
- sb.append(", GLES2 ");
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent);
+ } else {
+ sb.append(", GLES2 ");
+ }
avail=isAvailableImpl(map, GLES2);
sb.append(avail);
if(avail) {
- glAvailabilityToString(device, sb, 2, GLContext.CTX_PROFILE_ES);
+ glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES);
}
- sb.append("], Profiles[");
+ if(useIndent) {
+ indentCount--;
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles");
+ indentCount++;
+ } else {
+ sb.append("], Profiles[");
+ }
+
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());
- sb.append(", ");
+ if(!useIndent) {
+ sb.append(", ");
+ }
+ }
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("default ");
+ } else {
+ sb.append(", default ");
}
- sb.append(", default ");
try {
sb.append(getDefault(device));
} catch (GLException gle) {
sb.append("n/a");
}
}
- sb.append("]]");
+ if(useIndent) {
+ sb.append(Platform.getNewline());
+ } else {
+ sb.append("]");
+ }
- return sb.toString();
+ return sb;
}
/** Uses the default device */
@@ -1198,11 +1272,9 @@ public class GLProfile {
private static /*final*/ boolean hasGLES2Impl;
private static /*final*/ boolean hasGLES1Impl;
- private static /*final*/ GLDrawableFactoryImpl eglFactory;
- private static /*final*/ GLDrawableFactoryImpl desktopFactory;
- private static /*final*/ AbstractGraphicsDevice defaultDevice;
- private static /*final*/ AbstractGraphicsDevice defaultDesktopDevice;
- private static /*final*/ AbstractGraphicsDevice defaultEGLDevice;
+ private static /*final*/ GLDrawableFactoryImpl eglFactory = null;
+ private static /*final*/ GLDrawableFactoryImpl desktopFactory = null;
+ private static /*final*/ AbstractGraphicsDevice defaultDevice = null;
private static volatile boolean initialized = false;
private static RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock();
@@ -1270,11 +1342,10 @@ public class GLProfile {
}
if(null == desktopFactory) {
- hasDesktopGLFactory = false;
- hasGL234Impl = false;
+ hasDesktopGLFactory = false;
+ hasGL234Impl = false;
} else {
- defaultDesktopDevice = desktopFactory.getDefaultDevice();
- defaultDevice = defaultDesktopDevice;
+ defaultDevice = desktopFactory.getDefaultDevice();
}
if ( ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) {
@@ -1283,15 +1354,9 @@ public class GLProfile {
eglFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2);
if(null != eglFactory) {
hasEGLFactory = true;
- GLDynamicLookupHelper eglLookupHelper = eglFactory.getGLDynamicLookupHelper(2);
// update hasGLES1Impl, hasGLES2Impl based on EGL
- if(null!=eglLookupHelper) {
- hasGLES2Impl = eglLookupHelper.isLibComplete() && hasGLES2Impl;
- }
- eglLookupHelper = eglFactory.getGLDynamicLookupHelper(1);
- if(null!=eglLookupHelper) {
- hasGLES1Impl = eglLookupHelper.isLibComplete() && hasGLES1Impl;
- }
+ hasGLES2Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES2Impl;
+ hasGLES1Impl = null!=eglFactory.getGLDynamicLookupHelper(1) && hasGLES1Impl;
}
} catch (LinkageError le) {
t=le;
@@ -1313,31 +1378,25 @@ public class GLProfile {
}
if(null == eglFactory) {
- hasGLES2Impl = false;
- hasGLES1Impl = false;
- } else {
- defaultEGLDevice = eglFactory.getDefaultDevice();
- if (null==defaultDevice) {
- defaultDevice = defaultEGLDevice;
- }
+ hasGLES2Impl = false;
+ hasGLES1Impl = false;
+ } else if(null == defaultDevice) {
+ defaultDevice = eglFactory.getDefaultDevice();
}
- final boolean addedDesktopProfile = initProfilesForDevice(defaultDesktopDevice);
- final boolean addedEGLProfile = initProfilesForDevice(defaultEGLDevice);
- final boolean addedAnyProfile = addedDesktopProfile || addedEGLProfile ;
+ final boolean addedAnyProfile = initProfilesForDevice(defaultDevice);
if(DEBUG) {
- System.err.println("GLProfile.init addedAnyProfile(d/e) "+addedAnyProfile+" ("+addedDesktopProfile+"/"+addedEGLProfile+")");
+ System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile);
System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable);
System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory);
System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl);
System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory);
System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl);
System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl);
- System.err.println("GLProfile.init defaultDesktopDevice "+defaultDesktopDevice);
- System.err.println("GLProfile.init defaultEGLDevice "+defaultEGLDevice);
System.err.println("GLProfile.init defaultDevice "+defaultDevice);
- System.err.println("GLProfile.init: "+array2String(GL_PROFILE_LIST_ALL)+", "+ glAvailabilityToString());
+ System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL));
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(null));
}
}
@@ -1408,8 +1467,12 @@ public class GLProfile {
1, 5, GLContext.CTX_PROFILE_COMPAT|GLContext.CTX_OPTION_ANY);
}
addedDesktopProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */);
- } else if( hasEGLFactory && ( hasGLES2Impl || hasGLES1Impl ) &&
- ( deviceIsEGLCompatible = eglFactory.getIsDeviceCompatible(device)) ) {
+ }
+
+ // also test GLES1 and GLES2 on desktop, since we have implementations / emulations available
+ if( hasEGLFactory && ( hasGLES2Impl || hasGLES1Impl ) &&
+ ( deviceIsEGLCompatible = eglFactory.getIsDeviceCompatible(device)) ) {
+
// 1st pretend we have all EGL profiles ..
computeProfileMap(device, false /* desktopCtxUndef*/, true /* esCtxUndef */);
@@ -1434,22 +1497,22 @@ public class GLProfile {
if (DEBUG) {
System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail);
}
- if(hasGLES2Impl && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES) ) {
- // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent},
- // so we have to add the usual suspect
+ if( hasGLES2Impl ) {
+ // The native ES2 impl. overwrites a previous mapping using 'ES2 compatibility' by a desktop profile
GLContext.mapAvailableGLVersion(device,
2, GLContext.CTX_PROFILE_ES,
- 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY);
+ 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY|GLContext.CTX_IMPL_ES2_COMPAT);
}
- if(hasGLES1Impl && null == GLContext.getAvailableGLVersion(device, 1, GLContext.CTX_PROFILE_ES)) {
- // nobody yet set the available desktop versions, see {@link GLContextImpl#makeCurrent},
- // so we have to add the usual suspect
+ if( hasGLES1Impl ) {
+ // Always favor the native ES1 impl.
GLContext.mapAvailableGLVersion(device,
1, GLContext.CTX_PROFILE_ES,
1, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_OPTION_ANY);
}
addedEGLProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */);
- } else {
+ }
+
+ if( !addedDesktopProfile && !addedEGLProfile ) {
setProfileMap(device, new HashMap<String /*GLProfile_name*/, GLProfile>()); // empty
if(DEBUG) {
System.err.println("GLProfile: device could not be initialized: "+device);
@@ -1507,16 +1570,6 @@ public class GLProfile {
return defaultDevice;
}
- public static AbstractGraphicsDevice getDefaultDesktopDevice() {
- initSingleton();
- return defaultDesktopDevice;
- }
-
- public static AbstractGraphicsDevice getDefaultEGLDevice() {
- initSingleton();
- return defaultEGLDevice;
- }
-
private static String array2String(String[] list) {
StringBuffer msg = new StringBuffer();
msg.append("[");
@@ -1529,7 +1582,7 @@ public class GLProfile {
return msg.toString();
}
- private static void glAvailabilityToString(AbstractGraphicsDevice device, StringBuffer sb, int major, int profile) {
+ private static void glAvailabilityToString(AbstractGraphicsDevice device, StringBuilder sb, int major, int profile) {
String str = GLContext.getAvailableGLVersionAsString(device, major, profile);
if(null==str) {
throw new GLException("Internal Error");
@@ -1646,6 +1699,20 @@ public class GLProfile {
return GL2;
} else if(GLES2.equals(profile) && hasGLES2Impl && ( esCtxUndef || GLContext.isGLES2Available(device))) {
return GLES2;
+ /**
+ * TODO: GLES2_TRUE_DESKTOP (see: GLContextImpl, GLProfile)
+ * Hack to enable GLES2 for desktop profiles w/ ES2 compatibility,
+ * however .. a consequent implementation would need to have all GL2ES2
+ * implementing profile to also implement GLES2!
+ * Let's rely on GL2ES2 and let the user/impl. query isGLES2Compatible()
+ } else if(GLES2.equals(profile)) {
+ if(hasGL234Impl || hasGLES2Impl) {
+ if(esCtxUndef) {
+ return GLES2;
+ }
+ return GLContext.getAvailableGLProfile(device, 2, GLContext.CTX_PROFILE_ES);
+ }
+ */
} else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device))) {
return GLES1;
}
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 1190af677..9c5263b37 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -57,7 +57,6 @@ import java.awt.geom.Rectangle2D;
import java.awt.EventQueue;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.List;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.OffscreenLayerOption;
@@ -234,7 +233,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
super();
if(null==capsReqUser) {
- capsReqUser = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDesktopDevice()));
+ capsReqUser = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDevice()));
} else {
// don't allow the user to change data
capsReqUser = (GLCapabilitiesImmutable) capsReqUser.cloneMutable();
@@ -1079,13 +1078,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
// System.err.println(NativeWindowVersion.getInstance());
System.err.println(JoglVersion.getInstance());
- final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
- final List<GLCapabilitiesImmutable> availCaps = factory.getAvailableCapabilities(null);
- for(int i=0; i<availCaps.size(); i++) {
- System.err.println(availCaps.get(i));
- }
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(null).toString());
- final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDesktopDevice()) );
+ final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) );
final Frame frame = new Frame("JOGL AWT Test");
final GLCanvas glCanvas = new GLCanvas(caps);
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 7a87882ca..4ccd3c97c 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -245,7 +245,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if (userCapsRequest != null) {
caps = (GLCapabilities) userCapsRequest.cloneMutable();
} else {
- caps = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDesktopDevice()));
+ caps = new GLCapabilities(GLProfile.getDefault(GLProfile.getDefaultDevice()));
}
caps.setDoubleBuffered(false);
offscreenCaps = caps;
@@ -1336,7 +1336,7 @@ public void reshape(int x, int y, int width, int height) {
public GLProfile getGLProfile() {
// FIXME: should do better than this; is it possible to using only platform-independent code?
- return GLProfile.getDefault(GLProfile.getDefaultDesktopDevice());
+ return GLProfile.getDefault(GLProfile.getDefaultDevice());
}
public void handleReshape() {
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index a7710e5bc..02ac2428f 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -653,11 +653,12 @@ public abstract class GLContextImpl extends GLContext {
private final void mapGLVersions(AbstractGraphicsDevice device) {
synchronized (GLContext.deviceVersionAvailable) {
+ // Following GLProfile.GL_PROFILE_LIST_ALL order of profile detection { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }
createContextARBMapVersionsAvailable(4, true /* compat */); // GL4bc
- createContextARBMapVersionsAvailable(4, false /* core */); // GL4
createContextARBMapVersionsAvailable(3, true /* compat */); // GL3bc
+ createContextARBMapVersionsAvailable(2, true /* compat */); // GL2
+ createContextARBMapVersionsAvailable(4, false /* core */); // GL4
createContextARBMapVersionsAvailable(3, false /* core */); // GL3
- createContextARBMapVersionsAvailable(2, true /* compat */); // GL2
GLContext.setAvailableGLVersionsSet(device);
resetStates();
}
@@ -717,14 +718,21 @@ public abstract class GLContextImpl extends GLContext {
}
if(0!=_context) {
AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice();
- if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) {
- ctp |= CTX_PROFILE_ES2_COMPAT;
- }
- GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major[0], minor[0], ctp);
+ // ctxMajorVersion, ctxMinorVersion, ctxOptions is being set by
+ // createContextARBVersions(..) -> setGLFunctionAvailbility(..) -> setContextVersion(..)
+ GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxMajorVersion, ctxMinorVersion, ctxOptions);
+ /**
+ * TODO: GLES2_TRUE_DESKTOP (see: GLContextImpl, GLProfile)
+ * Hack to enable GLES2 for desktop profiles w/ ES2 compatibility,
+ * however .. a consequent implementation would need to have all GL2ES2
+ * implementing profile to also implement GLES2!
+ * Let's rely on GL2ES2 and let the user/impl. query isGLES2Compatible()
+ if( isGLES2Compatible() && null == GLContext.getAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES) ) {
+ GLContext.mapAvailableGLVersion(device, 2, GLContext.CTX_PROFILE_ES, ctxMajorVersion, ctxMinorVersion, ctxOptions);
+ }*/
destroyContextARBImpl(_context);
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: "+
- GLContext.getAvailableGLVersionAsString(device, reqMajor, reqProfile));
+ System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable HAVE: " + getGLVersion());
}
} else if (DEBUG) {
System.err.println(getThreadName() + ": !!! createContextARBMapVersionsAvailable NOPE: "+reqMajor+"."+reqProfile);
@@ -929,24 +937,24 @@ public abstract class GLContextImpl extends GLContext {
* @see #setContextVersion
* @see javax.media.opengl.GLContext#CTX_OPTION_ANY
* @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT
+ * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT
*/
protected final void setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits) {
if(null!=this.gl && null!=glProcAddressTable && !force) {
return; // already done and not forced
}
-
+
if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) {
setGL(createGL(getGLDrawable().getGLProfile()));
}
-
updateGLXProcAddressTable();
AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
- final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT;
- contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits);
+ ctxProfileBits |= drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT;
+ contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits);
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN);
+ System.err.println(getThreadName() + ": !!! Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null));
}
//
@@ -956,8 +964,8 @@ public abstract class GLContextImpl extends GLContext {
synchronized(mappedContextTypeObjectLock) {
table = mappedGLProcAddress.get( contextFQN );
if(null != table && !verifyInstance(gl.getGLProfile(), "ProcAddressTable", table)) {
- throw new InternalError("GLContext GL ProcAddressTable mapped key("+contextFQN+") -> "+
- table.getClass().getName()+" not matching "+gl.getGLProfile().getGLImplBaseClassName());
+ throw new InternalError("GLContext GL ProcAddressTable mapped key("+contextFQN+" - " + GLContext.getGLVersion(major, minor, ctxProfileBits, null)+
+ ") -> "+ table.getClass().getName()+" not matching "+gl.getGLProfile().getGLImplBaseClassName());
}
}
if(null != table) {
@@ -981,11 +989,6 @@ public abstract class GLContextImpl extends GLContext {
}
//
- // Set GL Version
- //
- setContextVersion(major, minor, ctxProfileBits);
-
- //
// Update ExtensionAvailabilityCache
//
ExtensionAvailabilityCache eCache;
@@ -1008,16 +1011,24 @@ public abstract class GLContextImpl extends GLContext {
System.err.println(getThreadName() + ": !!! GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+extensionAvailability.hashCode());
}
}
+ }
+ if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) {
+ ctxProfileBits |= CTX_IMPL_ES2_COMPAT;
}
+
+ //
+ // Set GL Version
+ //
+ setContextVersion(major, minor, ctxProfileBits);
}
protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) {
AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
- final int ctxImplBits = drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT;
- contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits, ctxImplBits);
+ ctxProfileBits |= drawable.getChosenGLCapabilities().getHardwareAccelerated() ? GLContext.CTX_IMPL_ACCEL_HARD : GLContext.CTX_IMPL_ACCEL_SOFT;
+ contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits);
if (DEBUG) {
- System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN);
+ System.err.println(getThreadName() + ": !!! RM Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null));
}
synchronized(mappedContextTypeObjectLock) {
@@ -1129,8 +1140,9 @@ public abstract class GLContextImpl extends GLContext {
return false;
}
- protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits, int ctxImplBits) {
- return device.getUniqueID() + "-" + toHexString(compose8bit(major, minor, ctxProfileBits, ctxImplBits));
+ protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) {
+ ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT ; // remove non-key value
+ return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits));
}
protected String getContextFQN() {
diff --git a/src/jogl/classes/jogamp/opengl/awt/Java2D.java b/src/jogl/classes/jogamp/opengl/awt/Java2D.java
index 3e4a6a147..b5530fc2f 100644
--- a/src/jogl/classes/jogamp/opengl/awt/Java2D.java
+++ b/src/jogl/classes/jogamp/opengl/awt/Java2D.java
@@ -567,7 +567,7 @@ public class Java2D {
}
invokeWithOGLSharedContextCurrent(device.getDefaultConfiguration(), new Runnable() {
public void run() {
- j2dFBOShareContext = GLDrawableFactory.getFactory(GLProfile.getDefault(GLProfile.getDefaultDesktopDevice())).createExternalGLContext();
+ j2dFBOShareContext = GLDrawableFactory.getFactory(GLProfile.getDefault(GLProfile.getDefaultDevice())).createExternalGLContext();
}
});
if (DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java
new file mode 100644
index 000000000..cddd142e9
--- /dev/null
+++ b/src/jogl/classes/jogamp/opengl/egl/DesktopES2DynamicLibraryBundleInfo.java
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * 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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * 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 jogamp.opengl.egl;
+
+import java.util.*;
+
+import jogamp.opengl.*;
+
+/**
+ * Implementation of the DynamicLookupHelper for Desktop ES2 (AMD, ..)
+ * where EGL and ES2 functions reside within the desktop OpenGL library.
+ */
+public class DesktopES2DynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo {
+ static List<String> glueLibNames;
+ static {
+ glueLibNames = new ArrayList<String>();
+ glueLibNames.add("jogl_mobile");
+ }
+
+ protected DesktopES2DynamicLibraryBundleInfo() {
+ super();
+ }
+
+ /**
+ * Might be a desktop GL library, and might need to allow symbol access to subsequent libs.
+ *
+ * This respects old DRI requirements:<br>
+ * <pre>
+ * http://dri.sourceforge.net/doc/DRIuserguide.html
+ * </pre>
+ */
+ public boolean shallLinkGlobal() { return true; }
+
+ public final List<String> getToolGetProcAddressFuncNameList() {
+ List<String> res = new ArrayList<String>();
+ res.add("eglGetProcAddress");
+ return res;
+ }
+
+ public final long toolGetProcAddress(long toolGetProcAddressHandle, String funcName) {
+ return EGL.eglGetProcAddress(toolGetProcAddressHandle, funcName);
+ }
+
+ public final boolean useToolGetProcAdressFirst(String funcName) {
+ return true;
+ }
+
+ public List<List<String>> getToolLibNames() {
+ final List<List<String>> libsList = new ArrayList<List<String>>();
+ final List<String> libsGL = new ArrayList<String>();
+
+ // Be aware that on DRI systems, eg ATI fglrx, etc,
+ // you have to set LIBGL_DRIVERS_PATH env variable.
+ // Eg on Ubuntu 64bit systems this is:
+ // export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri
+ //
+
+ // X11: this is the default lib name, according to the spec
+ libsGL.add("libGL.so.1");
+
+ // X11: try this one as well, if spec fails
+ libsGL.add("libGL.so");
+
+ // Windows default
+ libsGL.add("OpenGL32");
+
+ // OSX (guess ES2 on OSX will never happen)
+ libsGL.add("/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib");
+
+ // last but not least .. the generic one
+ libsGL.add("GL");
+
+ libsList.add(libsGL);
+ return libsList;
+ }
+
+ public final List<String> getGlueLibNames() {
+ return glueLibNames;
+ }
+}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 62ee20f92..1dc4a81aa 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -108,7 +108,7 @@ public abstract class EGLContext extends GLContextImpl {
drawableRead.getHandle(),
contextHandle)) {
throw new GLException("Error making context 0x" +
- Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError());
+ Long.toHexString(contextHandle) + " current: error code 0x" + Integer.toHexString(EGL.eglGetError()));
}
}
}
@@ -119,14 +119,17 @@ public abstract class EGLContext extends GLContextImpl {
EGL.EGL_NO_SURFACE,
EGL.EGL_NO_CONTEXT)) {
throw new GLException("Error freeing OpenGL context 0x" +
- Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError());
+ Long.toHexString(contextHandle) + ": error code 0x" + Integer.toHexString(EGL.eglGetError()));
}
}
protected void destroyImpl() throws GLException {
if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), contextHandle)) {
- throw new GLException("Error destroying OpenGL context 0x" +
- Long.toHexString(contextHandle) + ": error code " + EGL.eglGetError());
+ final int eglError = EGL.eglGetError();
+ if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */
+ throw new GLException("Error destroying OpenGL context 0x" +
+ Long.toHexString(contextHandle) + ": error code 0x" + Integer.toHexString(eglError));
+ }
}
}
@@ -204,7 +207,7 @@ public abstract class EGLContext extends GLContextImpl {
int ctp = CTX_PROFILE_ES|CTX_OPTION_ANY;
int major;
if(glProfile.usesNativeGLES2()) {
- ctp |= CTX_PROFILE_ES2_COMPAT;
+ ctp |= CTX_IMPL_ES2_COMPAT;
major = 2;
} else {
major = 1;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
index 14a0a40cd..db1efc194 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -89,7 +89,23 @@ public abstract class EGLDrawable extends GLDrawableImpl {
eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), surface.getSurfaceHandle());
if (EGL.EGL_NO_SURFACE==eglSurface) {
- throw new GLException("Creation of window surface failed: "+eglConfig+", error "+toHexString(EGL.eglGetError()));
+ final int eglError0 = EGL.eglGetError();
+ if(EGL.EGL_BAD_NATIVE_WINDOW == eglError0) {
+ // Try window handle if available and differs (Windows HDC / HWND).
+ // ANGLE impl. required HWND on Windows.
+ if(surface instanceof NativeWindow) {
+ final NativeWindow nw = (NativeWindow) surface;
+ if(nw.getWindowHandle() != nw.getSurfaceHandle()) {
+ if(DEBUG) {
+ System.err.println("Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle");
+ }
+ eglSurface = createSurface(eglDisplay, eglConfig.getNativeConfig(), nw.getWindowHandle());
+ }
+ }
+ }
+ }
+ if (EGL.EGL_NO_SURFACE==eglSurface) {
+ throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(EGL.eglGetError()));
}
if(DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index cd6d61a22..56d14fc8f 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -47,7 +47,9 @@ import com.jogamp.common.util.*;
import jogamp.opengl.*;
import jogamp.nativewindow.WrappedSurface;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
@@ -73,7 +75,32 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// for each ES profile with their own ProcAddressTable.
synchronized(EGLDrawableFactory.class) {
- if(null==eglES1DynamicLookupHelper) {
+ /**
+ * Currently AMD's EGL impl. crashes at eglGetDisplay(EGL_DEFAULT_DISPLAY)
+ *
+ // Check Desktop ES2 Availability first (AMD, ..)
+ if(null==eglES2DynamicLookupHelper) {
+ GLDynamicLookupHelper tmp=null;
+ try {
+ tmp = new GLDynamicLookupHelper(new DesktopES2DynamicLibraryBundleInfo());
+ } catch (GLException gle) {
+ if(DEBUG) {
+ gle.printStackTrace();
+ }
+ }
+ if(null!=tmp && tmp.isLibComplete()) {
+ eglES2DynamicLookupHelper = tmp;
+ EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
+ if (GLProfile.DEBUG) {
+ System.err.println("Info: EGLDrawableFactory: Desktop ES2 - OK");
+ }
+ } else if (GLProfile.DEBUG) {
+ System.err.println("Info: EGLDrawableFactory: Desktop ES2 - NOPE");
+ }
+ } */
+ final boolean hasDesktopES2 = null != eglES2DynamicLookupHelper;
+
+ if(!hasDesktopES2 && null==eglES1DynamicLookupHelper) {
GLDynamicLookupHelper tmp=null;
try {
tmp = new GLDynamicLookupHelper(new EGLES1DynamicLibraryBundleInfo());
@@ -81,16 +108,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
if(DEBUG) {
gle.printStackTrace();
}
- }
- eglES1DynamicLookupHelper = tmp;
- if(null!=eglES1DynamicLookupHelper && eglES1DynamicLookupHelper.isLibComplete()) {
+ }
+ if(null!=tmp && tmp.isLibComplete()) {
+ eglES1DynamicLookupHelper = tmp;
EGL.resetProcAddressTable(eglES1DynamicLookupHelper);
- }
+ if (GLProfile.DEBUG) {
+ System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK");
+ }
+ } else if (GLProfile.DEBUG) {
+ System.err.println("Info: EGLDrawableFactory: EGL ES1 - NOPE");
+ }
}
- }
-
- synchronized(EGLDrawableFactory.class) {
- if(null==eglES2DynamicLookupHelper) {
+ if(!hasDesktopES2 && null==eglES2DynamicLookupHelper) {
GLDynamicLookupHelper tmp=null;
try {
tmp = new GLDynamicLookupHelper(new EGLES2DynamicLibraryBundleInfo());
@@ -98,21 +127,33 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
if(DEBUG) {
gle.printStackTrace();
}
- }
- eglES2DynamicLookupHelper = tmp;
- if(null!=eglES2DynamicLookupHelper && eglES2DynamicLookupHelper.isLibComplete()) {
+ }
+ if(null!=tmp && tmp.isLibComplete()) {
+ eglES2DynamicLookupHelper = tmp;
EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
- }
+ if (GLProfile.DEBUG) {
+ System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK");
+ }
+ } else if (GLProfile.DEBUG) {
+ System.err.println("Info: EGLDrawableFactory: EGL ES2 - NOPE");
+ }
}
}
if(null != eglES1DynamicLookupHelper || null != eglES2DynamicLookupHelper) {
defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- sharedMap = new HashMap();
}
}
protected final void destroy(ShutdownType shutdownType) {
if(null != sharedMap) {
+ Collection<SharedResource> srl = sharedMap.values();
+ for(Iterator<SharedResource> sri = srl.iterator(); sri.hasNext(); ) {
+ SharedResource sr = sri.next();
+ if(DEBUG) {
+ System.err.println("EGLDrawableFactory.destroy("+shutdownType+"): "+sr.device.toString());
+ }
+ EGL.eglTerminate(sr.device.getHandle());
+ }
sharedMap.clear();
sharedMap = null;
}
@@ -132,7 +173,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
} */
}
- private HashMap/*<connection, SharedResource>*/ sharedMap;
+ private HashMap<String /*connection*/, SharedResource> sharedMap = new HashMap<String /*connection*/, SharedResource>();
private EGLGraphicsDevice defaultDevice;
static class SharedResource {
@@ -199,12 +240,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
} */
/* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) {
+ if(null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper) {
+ return null;
+ }
String connection = adevice.getConnection();
SharedResource sr;
synchronized(sharedMap) {
sr = (SharedResource) sharedMap.get(connection);
}
- if(null==sr) {
+ if(null==sr) {
long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL.EGL_NO_DISPLAY) {
throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError()));
@@ -265,14 +309,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) {
if (2==esProfile) {
- if(null==eglES2DynamicLookupHelper) {
- throw new GLException("GLDynamicLookupHelper for ES2 not available");
- }
return eglES2DynamicLookupHelper;
} else if (1==esProfile) {
- if(null==eglES1DynamicLookupHelper) {
- throw new GLException("GLDynamicLookupHelper for ES1 not available");
- }
return eglES1DynamicLookupHelper;
} else {
throw new GLException("Unsupported: ES"+esProfile);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
index 50c4950a0..841d50f5f 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java
@@ -51,7 +51,14 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle
super();
}
- /** Might be a desktop GL library, and might need to allow symbol access to subsequent libs */
+ /**
+ * Might be a desktop GL library, and might need to allow symbol access to subsequent libs.
+ *
+ * This respects old DRI requirements:<br>
+ * <pre>
+ * http://dri.sourceforge.net/doc/DRIuserguide.html
+ * </pre>
+ */
public boolean shallLinkGlobal() { return true; }
public boolean shallLookupGlobal() {
@@ -74,19 +81,27 @@ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundle
}
public final boolean useToolGetProcAdressFirst(String funcName) {
- return false; // JAU / FIXME funcName.startsWith("egl");
+ if ( AndroidVersion.isAvailable ) {
+ // Android requires global dlsym lookup
+ return false;
+ } else {
+ return true;
+ }
}
protected List<String> getEGLLibNamesList() {
List<String> eglLibNames = new ArrayList<String>();
- // try default generic names first
- eglLibNames.add("EGL");
+ // this is the default EGL lib name, according to the spec
+ eglLibNames.add("libEGL.so.1");
+
+ // try these as well, if spec fails
+ eglLibNames.add("libEGL.so");
+ eglLibNames.add("EGL");
+
// for windows distributions using the 'unlike' lib prefix,
// where our tool does not add it.
eglLibNames.add("libEGL");
- // this is the default EGL lib name, according to the spec
- eglLibNames.add("libEGL.so.1");
return eglLibNames;
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
index 63109f445..0a373eb7f 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES1DynamicLibraryBundleInfo.java
@@ -40,11 +40,12 @@ public class EGLES1DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo
{
final List<String> libsGL = new ArrayList<String>();
- // GLESv2
- libsGL.add("GLESv1_CM");
- libsGL.add("libGLESv1_CM.so");
// this is the default lib name, according to the spec
libsGL.add("libGLESv1_CM.so.2");
+
+ // try these as well, if spec fails
+ libsGL.add("libGLESv1_CM.so");
+ libsGL.add("GLESv1_CM");
// alternative names
libsGL.add("GLES_CM");
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
index b0748ad10..d4ee852b1 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java
@@ -40,11 +40,12 @@ public class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo
{
final List<String> libsGL = new ArrayList<String>();
- // GLESv2
- libsGL.add("GLESv2");
- libsGL.add("libGLESv2.so");
// this is the default lib name, according to the spec
libsGL.add("libGLESv2.so.2");
+
+ // try these as well, if spec fails
+ libsGL.add("libGLESv2.so");
+ libsGL.add("GLESv2");
// alternative names
libsGL.add("GLES20");
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 5c6486799..ee28b7bcb 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -88,11 +88,12 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
gle.printStackTrace();
}
}
- macOSXCGLDynamicLookupHelper = tmp;
- /** FIXME ??
- if(null!=macOSXCGLDynamicLookupHelper) {
+ if(null!=tmp && tmp.isLibComplete()) {
+ macOSXCGLDynamicLookupHelper = tmp;
+ /** FIXME ??
CGL.getCGLProcAddressTable().reset(macOSXCGLDynamicLookupHelper);
- } */
+ */
+ }
}
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 43c16240d..f40a5f0bf 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -95,9 +95,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
if(DEBUG) {
gle.printStackTrace();
}
- }
- windowsWGLDynamicLookupHelper = tmp;
- if(null!=windowsWGLDynamicLookupHelper) {
+ }
+ if(null!=tmp && tmp.isLibComplete()) {
+ windowsWGLDynamicLookupHelper = tmp;
WGL.getWGLProcAddressTable().reset(windowsWGLDynamicLookupHelper);
}
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index acced638f..4e8a35fa5 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -93,9 +93,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
if(DEBUG) {
gle.printStackTrace();
}
- }
- x11GLXDynamicLookupHelper = tmp;
- if(null!=x11GLXDynamicLookupHelper) {
+ }
+ if(null!=tmp && tmp.isLibComplete()) {
+ x11GLXDynamicLookupHelper = tmp;
GLX.getGLXProcAddressTable().reset(x11GLXDynamicLookupHelper);
}
}