summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java99
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java10
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java13
3 files changed, 75 insertions, 47 deletions
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index bbe8d602b..cc37da0ff 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -42,7 +42,7 @@ package javax.media.opengl;
import java.nio.IntBuffer;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Set;
@@ -118,6 +118,19 @@ public abstract class GLContext {
/** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}. */
public static final int CONTEXT_CURRENT_NEW = 2;
+ /* Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
+ public static final VersionNumber Version100 = new VersionNumber(1, 0, 0);
+ /* Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
+ public static final VersionNumber Version110 = new VersionNumber(1, 10, 0);
+ /* Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
+ public static final VersionNumber Version120 = new VersionNumber(1, 20, 0);
+ /* Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
+ public static final VersionNumber Version130 = new VersionNumber(1, 30, 0);
+ /* Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
+ public static final VersionNumber Version140 = new VersionNumber(1, 40, 0);
+ /* Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
+ public static final VersionNumber Version150 = new VersionNumber(1, 50, 0);
+
/** Version 3.2. As an OpenGL version, it qualifies for geometry shader */
public static final VersionNumber Version32 = new VersionNumber(3, 2, 0);
@@ -716,9 +729,19 @@ public abstract class GLContext {
/**
* Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n',
- * i.e.:
+ * i.e. for desktop
* <pre>
* #version 110
+ * ..
+ * #version 150
+ * #version 330
+ * ...
+ * </pre>
+ * And for ES:
+ * <pre>
+ * #version 100
+ * #version 300 es
+ * ..
* </pre>
* <p>
* If context has not been made current yet, a string of zero length is returned.
@@ -730,31 +753,31 @@ public abstract class GLContext {
return "";
}
final int minor = ctxGLSLVersion.getMinor();
- return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + "\n" ;
+ final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version30) >= 0 ? " es" : "";
+ return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\n" ;
}
- protected static final void getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions, int[] res) {
+ protected static final VersionNumber getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions) {
if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) {
- res[0] = 1; res[1] = 0; // ES 2.0 -> GLSL 1.00
+ if( 3 > glMajorVersion ) {
+ return Version100; // ES 2.0 -> GLSL 1.00
+ }
} else if( 1 == glMajorVersion ) {
- res[0] = 1; res[1] = 10; // GL 1.x -> GLSL 1.10
+ return Version110; // GL 1.x -> GLSL 1.10
} else if( 2 == glMajorVersion ) {
- res[0] = 1;
switch ( glMinorVersion ) {
- case 0: res[1] = 10; break; // GL 2.0 -> GLSL 1.10
- default: res[1] = 20; break; // GL 2.1 -> GLSL 1.20
+ case 0: return Version110; // GL 2.0 -> GLSL 1.10
+ default: return Version120; // GL 2.1 -> GLSL 1.20
}
} else if( 3 == glMajorVersion && 2 >= glMinorVersion ) {
- res[0] = 1;
switch ( glMinorVersion ) {
- case 0: res[1] = 30; break; // GL 3.0 -> GLSL 1.30
- case 1: res[1] = 40; break; // GL 3.1 -> GLSL 1.40
- default: res[1] = 50; break; // GL 3.2 -> GLSL 1.50
+ case 0: return Version130; // GL 3.0 -> GLSL 1.30
+ case 1: return Version140; // GL 3.1 -> GLSL 1.40
+ default: return Version150; // GL 3.2 -> GLSL 1.50
}
- } else { // >= 3.3
- res[0] = glMajorVersion; // GL M.N -> GLSL M.N
- res[1] = glMinorVersion * 10;
}
+ // The new default: GL >= 3.3, ES >= 3.0
+ return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N
}
/**
@@ -813,15 +836,15 @@ public abstract class GLContext {
* </p>
*/
public final boolean hasFullFBOSupport() {
- return !FORCE_MIN_FBO_SUPPORT && hasBasicFBOSupport() &&
- ( isGL3() || // GL >= 3.0
- isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object
- ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object*
- isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) &&
- isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) &&
- isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil)
- )
- ) ;
+ return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) &&
+ ( isGL3() || // GL >= 3.0
+ isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object
+ ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object*
+ isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) &&
+ isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) &&
+ isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil)
+ )
+ ) ;
}
/**
@@ -1199,12 +1222,12 @@ public abstract class GLContext {
/**
* @see #getDeviceVersionAvailableKey(javax.media.nativewindow.AbstractGraphicsDevice, int, int)
*/
- protected static /*final*/ HashMap<String, Integer> deviceVersionAvailable = new HashMap<String, Integer>();
+ protected static final IdentityHashMap<String, Integer> deviceVersionAvailable = new IdentityHashMap<String, Integer>();
/**
* @see #getUniqueDeviceString(javax.media.nativewindow.AbstractGraphicsDevice)
*/
- private static /*final*/ HashSet<String> deviceVersionsAvailableSet = new HashSet<String>();
+ private static final IdentityHashMap<String, String> deviceVersionsAvailableSet = new IdentityHashMap<String, String>();
/** clears the device/context mappings as well as the GL/GLX proc address tables. */
protected static void shutdown() {
@@ -1215,17 +1238,16 @@ public abstract class GLContext {
protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) {
synchronized ( deviceVersionsAvailableSet ) {
- return deviceVersionsAvailableSet.contains(device.getUniqueID());
+ return deviceVersionsAvailableSet.containsKey(device.getUniqueID());
}
}
protected static void setAvailableGLVersionsSet(AbstractGraphicsDevice device) {
synchronized ( deviceVersionsAvailableSet ) {
- String devKey = device.getUniqueID();
- if ( deviceVersionsAvailableSet.contains(devKey) ) {
+ final String devKey = device.getUniqueID();
+ if( null != deviceVersionsAvailableSet.put(devKey, devKey) ) {
throw new InternalError("Already set: "+devKey);
}
- deviceVersionsAvailableSet.add(devKey);
if (DEBUG) {
System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey);
System.err.println(GLContext.dumpAvailableGLVersions(null).toString());
@@ -1233,8 +1255,13 @@ public abstract class GLContext {
}
}
+ /**
+ * Returns a unique String object using {@link String#intern()} for the given arguments,
+ * which object reference itself can be used as a key.
+ */
protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) {
- return device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0));
+ final String r = device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0));
+ return r.intern();
}
/**
@@ -1262,10 +1289,10 @@ public abstract class GLContext {
System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null));
// Thread.dumpStack();
}
- final String key = getDeviceVersionAvailableKey(device, reqMajor, profile);
+ final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, profile);
final Integer val = new Integer(composeBits(resMajor, resMinor, resCtp));
synchronized(deviceVersionAvailable) {
- return deviceVersionAvailable.put( key, val );
+ return deviceVersionAvailable.put( objectKey, val );
}
}
@@ -1305,10 +1332,10 @@ public abstract class GLContext {
* @return the available GL version as encoded with {@link #composeBits(int, int, int), otherwise <code>null</code>
*/
protected static Integer getAvailableGLVersion(AbstractGraphicsDevice device, int reqMajor, int reqProfile) {
- String key = getDeviceVersionAvailableKey(device, reqMajor, reqProfile);
+ final String objectKey = getDeviceVersionAvailableKey(device, reqMajor, reqProfile);
Integer val;
synchronized(deviceVersionAvailable) {
- val = deviceVersionAvailable.get( key );
+ val = deviceVersionAvailable.get( objectKey );
}
return val;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index dbf6df0de..55ad85c9c 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -211,7 +211,15 @@ public abstract class GLDrawableFactory {
// The latter requires shutdown at JVM-Shutdown only.
synchronized(glDrawableFactories) {
for(int i=0; i<glDrawableFactories.size(); i++) {
- glDrawableFactories.get(i).destroy();
+ final GLDrawableFactory gldf = glDrawableFactories.get(i);
+ try {
+ gldf.destroy();
+ } catch (Throwable t) {
+ System.err.println("GLDrawableFactory.shutdownImpl: Catched Exception during shutdown of "+gldf.getClass().getName());
+ if( DEBUG ) {
+ t.printStackTrace();
+ }
+ }
}
glDrawableFactories.clear();
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 7359e1b47..b11f359be 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -978,7 +978,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private final AWTGLPixelBufferProvider pixelBufferProvider;
private final boolean useSingletonBuffer;
private AWTGLPixelBuffer pixelBuffer;
- private boolean pixelBufferCheckSize;
// One of these is used to store the read back pixels before storing
// in the BufferedImage
@@ -1160,14 +1159,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer
pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(pixelAttribs);
}
- if( pixelBufferCheckSize ) {
- pixelBufferCheckSize = false;
- if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) {
- pixelBuffer.dispose();
- pixelBuffer = null;
- }
+ if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) {
+ pixelBuffer.dispose();
+ pixelBuffer = null;
}
-
if ( null == pixelBuffer ) {
if (0 >= panelWidth || 0 >= panelHeight ) {
return;
@@ -1300,8 +1295,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
}
}
}
-
- pixelBufferCheckSize = true;
return _drawable.isRealized();
}