aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--make/config/jogl/cgl-macosx.cfg2
-rw-r--r--make/config/jogl/gl-headers.cfg2
-rw-r--r--make/config/jogl/gl3-headers.cfg2
-rw-r--r--make/config/jogl/glu-gl2.cfg2
-rw-r--r--make/config/nativewindow/jawt-macosx.cfg2
-rw-r--r--make/scripts/tests.sh6
-rw-r--r--make/stub_includes/macosx/OpenGL/OpenGL.h3
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java99
-rw-r--r--src/jogl/classes/com/jogamp/opengl/JoglVersion.java2
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java37
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java129
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java148
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java57
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java4
-rw-r--r--src/jogl/native/macosx/MacOSXCustomCGLCode.c2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java18
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java105
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java12
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java51
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java33
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java83
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java87
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java68
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java136
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java109
33 files changed, 729 insertions, 504 deletions
diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg
index edb5bfbbf..a67ee8087 100644
--- a/make/config/jogl/cgl-macosx.cfg
+++ b/make/config/jogl/cgl-macosx.cfg
@@ -31,7 +31,7 @@ Opaque long NSOpenGLView *
Opaque long NSOpenGLPixelBuffer *
Opaque long NSOpenGLLayer *
-CustomCCode #include </usr/include/machine/types.h>
+CustomCCode #include <machine/types.h>
CustomCCode #include "macosx-window-system.h"
AccessControl createNSOpenGLLayerImpl PRIVATE
diff --git a/make/config/jogl/gl-headers.cfg b/make/config/jogl/gl-headers.cfg
index 073f9d9a0..0916fa348 100644
--- a/make/config/jogl/gl-headers.cfg
+++ b/make/config/jogl/gl-headers.cfg
@@ -20,7 +20,7 @@ CustomCCode #include <inttypes.h>
CustomCCode #include <stdlib.h>
CustomCCode /* Include the OpenGL headers */
CustomCCode #include <GL/gl.h>
-CustomCCode #include </usr/include/machine/types.h>
+CustomCCode #include <machine/types.h>
CustomCCode /* Provide Windows typedefs */
CustomCCode typedef void* LPVOID;
CustomCCode typedef unsigned int* PUINT;
diff --git a/make/config/jogl/gl3-headers.cfg b/make/config/jogl/gl3-headers.cfg
index a4c5cf62a..d76d3ae4c 100644
--- a/make/config/jogl/gl3-headers.cfg
+++ b/make/config/jogl/gl3-headers.cfg
@@ -15,7 +15,7 @@ CustomCCode #include <inttypes.h>
CustomCCode #include <stdlib.h>
CustomCCode #include <GL/glcorearb.h>
CustomCCode #include <GL/glcorearbext.h>
-CustomCCode #include </usr/include/machine/types.h>
+CustomCCode #include <machine/types.h>
CustomCCode /* Provide Windows typedefs */
CustomCCode typedef void* LPVOID;
CustomCCode typedef unsigned int* PUINT;
diff --git a/make/config/jogl/glu-gl2.cfg b/make/config/jogl/glu-gl2.cfg
index 491d9224f..a634e3113 100644
--- a/make/config/jogl/glu-gl2.cfg
+++ b/make/config/jogl/glu-gl2.cfg
@@ -18,7 +18,7 @@ CustomCCode #include <stddef.h>
CustomCCode #elif defined(__APPLE__)
CustomCCode #include <inttypes.h>
CustomCCode #include <jni.h>
-CustomCCode #include </usr/include/machine/types.h>
+CustomCCode #include <machine/types.h>
CustomCCode #elif defined(__unix__)
CustomCCode #include <inttypes.h>
CustomCCode #endif
diff --git a/make/config/nativewindow/jawt-macosx.cfg b/make/config/nativewindow/jawt-macosx.cfg
index 20260f693..5f6bbfd21 100644
--- a/make/config/nativewindow/jawt-macosx.cfg
+++ b/make/config/nativewindow/jawt-macosx.cfg
@@ -8,7 +8,7 @@ Opaque long NSView *
Opaque long CALayer *
CustomCCode #include <inttypes.h>
-CustomCCode #include </usr/include/machine/types.h>
+CustomCCode #include <machine/types.h>
StructPackage JAWT_MacOSXDrawingSurfaceInfo jogamp.nativewindow.jawt.macosx
EmitStruct JAWT_MacOSXDrawingSurfaceInfo
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index fd79b028e..3f4fe9c19 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -206,7 +206,7 @@ function jrun() {
#D_ARGS="-Dnativewindow.debug.ToolkitLock"
#D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL"
#D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState"
- #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil"
+ #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil"
#D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil"
#D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false"
#D_ARGS="-Dnewt.test.EDTMainThread -Dnewt.debug.MainThread"
@@ -300,7 +300,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $*
#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $*
@@ -355,7 +355,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $*
diff --git a/make/stub_includes/macosx/OpenGL/OpenGL.h b/make/stub_includes/macosx/OpenGL/OpenGL.h
index 3347209b3..86d831191 100644
--- a/make/stub_includes/macosx/OpenGL/OpenGL.h
+++ b/make/stub_includes/macosx/OpenGL/OpenGL.h
@@ -59,7 +59,8 @@ typedef enum _CGLPixelFormatAttribute {
*/
typedef enum _CGLOpenGLProfile {
kCGLOGLPVersion_Legacy = 0x1000, /* Legacy/Pre-OpenGL 3.0 */
- kCGLOGLPVersion_3_2_Core = 0x3200 /* OpenGL 3.2 Core */
+ kCGLOGLPVersion_GL3_Core = 0x3200, /* OpenGL 3 Core */
+ kCGLOGLPVersion_GL4_Core = 0x4100 /* OpenGL 4 Core */
} CGLOpenGLProfile;
/*
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
index 9c9129ae6..4a720a4f9 100644
--- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -27,7 +27,9 @@
*/
package com.jogamp.opengl;
-import java.util.List;
+import java.util.IdentityHashMap;
+
+import javax.media.nativewindow.AbstractGraphicsDevice;
/**
* GLRendererQuirks contains information of known bugs of various GL renderer.
@@ -189,17 +191,80 @@ public class GLRendererQuirks {
*/
public static final int GLSLNonCompliant = 12;
+ /**
+ * GL4 context needs to be requested via GL3
+ * <ul>
+ * <li>OSX >= 10.9.0 - kCGLOGLPVersion_GL4_Core may not produce hw-accel context. Bug 867 @ https://jogamp.org/bugzilla/.</li>
+ * </ul>
+ */
+ public static final int GL4NeedsGL3Request = 13;
+
/** Number of quirks known. */
- public static final int COUNT = 13;
+ public static final int COUNT = 14;
private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
"NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard",
"GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display",
"NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext",
- "NoFullFBOSupport", "GLSLNonCompliant"
+ "NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request"
};
- private final int _bitmask;
+ private static final IdentityHashMap<String, GLRendererQuirks> stickyDeviceQuirks = new IdentityHashMap<String, GLRendererQuirks>();
+
+ /**
+ * Retrieval of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}.
+ * <p>
+ * Not thread safe.
+ * </p>
+ */
+ public static GLRendererQuirks getStickyDeviceQuirks(AbstractGraphicsDevice device) {
+ final String key = device.getUniqueID();
+ final GLRendererQuirks has = stickyDeviceQuirks.get(key);
+ final GLRendererQuirks res;
+ if( null == has ) {
+ res = new GLRendererQuirks();
+ stickyDeviceQuirks.put(key, res);
+ } else {
+ res = has;
+ }
+ return res;
+ }
+
+ /**
+ * {@link #addQuirks(int[], int, int) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}.
+ * <p>
+ * Not thread safe.
+ * </p>
+ */
+ public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, int[] quirks, int offset, int len) throws IllegalArgumentException {
+ final GLRendererQuirks sq = getStickyDeviceQuirks(device);
+ sq.addQuirks(quirks, offset, len);
+ }
+ /**
+ * {@link #exist(int) Query} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}.
+ * <p>
+ * Not thread safe. However, use after changing the sticky quirks is safe.
+ * </p>
+ */
+ public static boolean existStickyDeviceQuirk(AbstractGraphicsDevice device, int quirk) {
+ return getStickyDeviceQuirks(device).exist(quirk);
+ }
+ /**
+ * {@link #addQuirks(GLRendererQuirks) Pushing} the sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}
+ * to the given {@link GLRendererQuirks destination}.
+ * <p>
+ * Not thread safe. However, use after changing the sticky quirks is safe.
+ * </p>
+ */
+ public static void pushStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks dest) {
+ dest.addQuirks(getStickyDeviceQuirks(device));
+ }
+
+ private int _bitmask;
+
+ public GLRendererQuirks() {
+ _bitmask = 0;
+ }
/**
* @param quirks an array of valid quirks
@@ -208,6 +273,17 @@ public class GLRendererQuirks {
* @throws IllegalArgumentException if one of the quirks is out of range
*/
public GLRendererQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException {
+ this();
+ addQuirks(quirks, offset, len);
+ }
+
+ /**
+ * @param quirks an array of valid quirks to be added
+ * @param offset offset in quirks array to start reading
+ * @param len number of quirks to read from offset within quirks array
+ * @throws IllegalArgumentException if one of the quirks is out of range
+ */
+ public final void addQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException {
int bitmask = 0;
if( !( 0 <= offset + len && offset + len < quirks.length ) ) {
throw new IllegalArgumentException("offset and len out of bounds: offset "+offset+", len "+len+", array-len "+quirks.length);
@@ -217,21 +293,14 @@ public class GLRendererQuirks {
validateQuirk(quirk);
bitmask |= 1 << quirk;
}
- _bitmask = bitmask;
+ _bitmask |= bitmask;
}
/**
- * @param quirks a list of valid quirks
- * @throws IllegalArgumentException if one of the quirks is out of range
+ * @param quirks valid GLRendererQuirks to be added
*/
- public GLRendererQuirks(List<Integer> quirks) throws IllegalArgumentException {
- int bitmask = 0;
- for(int i=0; i<quirks.size(); i++) {
- final int quirk = quirks.get(i);
- validateQuirk(quirk);
- bitmask |= 1 << quirk;
- }
- _bitmask = bitmask;
+ public final void addQuirks(GLRendererQuirks quirks) {
+ _bitmask |= quirks._bitmask;
}
/**
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
index 1f715c21a..40f0d180f 100644
--- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
+++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java
@@ -115,7 +115,7 @@ public class JoglVersion extends JogampVersion {
if(null == device) {
device = GLProfile.getDefaultDevice();
}
- sb.append("Default Profiles on device ").append(device).append(Platform.getNewline());
+ sb.append("GLProfiles on device ").append(device).append(Platform.getNewline());
if(null!=device) {
GLProfile.glAvailabilityToString(device, sb, "\t", 1);
} else {
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 9f2e96781..55050f25c 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -149,11 +149,11 @@ public abstract class GLContext {
// Cached keys, bits [0..15]
//
- /** Context option bits, full bit mask covering bits [0..15], i.e. <code>0x0000FFFF</code>, {@value}. */
+ /** Context option bits, full bit mask covering 16 bits [0..15], i.e. <code>0x0000FFFF</code>, {@value}. */
protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF;
- /** Context option bits, cached bit mask covering 9 bits [0..8], i.e. <code>0x000001FF</code>, {@value}. Leaving 7 bits for non cached options, i.e. 9:7. */
- protected static final int CTX_IMPL_CACHE_MASK = 0x000001FF;
+ /** Context option bits, cached bit mask covering 10 bits [0..9], i.e. <code>0x000003FF</code>, {@value}. Leaving 6 bits for non cached options, i.e. 10:6. */
+ protected static final int CTX_IMPL_CACHE_MASK = 0x000003FF;
/** <code>ARB_create_context</code> related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
protected static final int CTX_IS_ARB_CREATED = 1 << 0;
@@ -171,14 +171,14 @@ public abstract class GLContext {
protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6;
//
- // Non cached keys, bits [9..15]
+ // Non cached keys, 6 bits [10..15]
//
/** <code>GL_ARB_ES2_compatibility</code> implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_IMPL_ES2_COMPAT = 1 << 9;
+ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10;
/** <code>GL_ARB_ES3_compatibility</code> implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */
- protected static final int CTX_IMPL_ES3_COMPAT = 1 << 10;
+ protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11;
/**
* Context supports basic FBO, details see {@link #hasBasicFBOSupport()}.
@@ -186,7 +186,7 @@ public abstract class GLContext {
* @see #hasBasicFBOSupport()
* @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
*/
- protected static final int CTX_IMPL_FBO = 1 << 11;
+ protected static final int CTX_IMPL_FBO = 1 << 12;
/**
* Context supports <code>OES_single_precision</code>, fp32, fixed function point (FFP) compatibility entry points,
@@ -195,7 +195,7 @@ public abstract class GLContext {
* @see #hasFP32CompatAPI()
* @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)
*/
- protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 12;
+ protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 13;
private static final ThreadLocal<GLContext> currentContext = new ThreadLocal<GLContext>();
@@ -1668,7 +1668,8 @@ public abstract class GLContext {
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; }
+ if(major == 3) { return GLProfile.GLES3; }
+ else 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));
@@ -1719,15 +1720,27 @@ public abstract class GLContext {
* @param device the device the profile is being requested
* @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 regarding availability, version and profile bits.
+ * @return the highest GLProfile for the device regarding availability, version and profile bits.
*/
protected static GLProfile getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile)
throws GLException {
+ final String glpName = getAvailableGLProfileName(device, reqMajor, reqProfile);
+ return null != glpName ? GLProfile.get(device, glpName) : null;
+ }
+
+ /**
+ * @param device the device the profile is being requested
+ * @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 name for the device regarding availability, version and profile bits.
+ */
+ /* package */ static String getAvailableGLProfileName(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 GLProfile.get(GLContext.getGLProfile(major[0], minor[0], ctp[0]));
+ return GLContext.getGLProfile(major[0], minor[0], ctp[0]);
}
return null;
}
@@ -1870,7 +1883,7 @@ public abstract class GLContext {
needColon = appendString(sb, "ES2 compat", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp ));
needColon = appendString(sb, "ES3 compat", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp ));
needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp ));
- needColon = appendString(sb, "FP32 compat-api", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp ));
+ needColon = appendString(sb, "FP32 compat", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp ));
if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) {
needColon = appendString(sb, "software", needColon, true);
} else {
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 35dcce0f7..c04971176 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -61,8 +61,8 @@ import javax.media.opengl.fixedfunc.GLPointerFunc;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* Specifies the the OpenGL profile.
@@ -267,138 +267,182 @@ public class GLProfile {
initSingleton();
+ int allCount = 0;
+ int nativeCount = 0;
+
if(null==device) {
device = defaultDevice;
}
final HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device, false);
if(useIndent) {
- doIndent(sb, indent, indentCount).append("Native");
+ doIndent(sb, indent, indentCount).append("Natives");
indentCount++;
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4bc").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc).append(indent);
} else {
- sb.append("Native[GL4bc ");
+ sb.append("Natives["+GL4bc+" ");
}
avail=isAvailableImpl(map, GL4bc);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_COMPAT);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4).append(indent);
} else {
- sb.append(", GL4 ");
+ sb.append(", "+GL4+" ");
}
avail=isAvailableImpl(map, GL4);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3).append(indent);
} else {
- sb.append(", GLES3 ");
+ sb.append(", "+GLES3+" ");
}
avail=isAvailableImpl(map, GLES3);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc).append(indent);
} else {
- sb.append(", GL3bc ");
+ sb.append(", "+GL3bc+" ");
}
avail=isAvailableImpl(map, GL3bc);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_COMPAT);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3).append(indent);
} else {
- sb.append(", GL3 ");
+ sb.append(", "+GL3+" ");
}
avail=isAvailableImpl(map, GL3);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_CORE);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2).append(indent);
} else {
- sb.append(", GL2 ");
+ sb.append(", "+GL2+" ");
}
avail=isAvailableImpl(map, GL2);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2).append(indent);
} else {
- sb.append(", GLES2 ");
+ sb.append(", "+GLES2+" ");
}
avail=isAvailableImpl(map, GLES2);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES);
}
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1).append(indent);
} else {
- sb.append(", GLES1 ");
+ sb.append(", "+GLES1+" ");
}
avail=isAvailableImpl(map, GLES1);
sb.append(avail);
if(avail) {
+ nativeCount++;
glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES);
}
+ allCount++;
+
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+nativeCount+" / "+allCount);
+ indentCount--;
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Common");
+ indentCount++;
+ } else {
+ sb.append(", count "+nativeCount+" / "+allCount+"], Common[");
+ }
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3).append(indent);
} else {
- sb.append(", GL4ES3 ");
+ sb.append(", "+GL4ES3+" ");
}
sb.append(isAvailableImpl(map, GL4ES3));
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3).append(indent);
} else {
- sb.append(", GL2ES2 ");
+ sb.append(", "+GL2GL3+" ");
+ }
+ sb.append(isAvailableImpl(map, GL2GL3));
+ allCount++;
+
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2).append(indent);
+ } else {
+ sb.append(", "+GL2ES2+" ");
}
sb.append(isAvailableImpl(map, GL2ES2));
+ allCount++;
if(useIndent) {
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent);
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1).append(indent);
} else {
- sb.append(", GL2ES1 ");
+ sb.append(", "+GL2ES1+" ");
}
sb.append(isAvailableImpl(map, GL2ES1));
+ allCount++;
if(useIndent) {
indentCount--;
- doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles");
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Mappings");
indentCount++;
} else {
- sb.append("], Profiles[");
+ sb.append("], Mappings[");
}
+ int profileCount = 0;
+
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());
- if(!useIndent) {
- sb.append(", ");
+ for (Map.Entry<String,GLProfile> entry : map.entrySet()) {
+ if( !GL_DEFAULT.equals(entry.getKey()) ) {
+ if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount);
+ }
+ sb.append(entry.getKey()+(useIndent?"\t":" ")+entry.getValue());
+ if(!useIndent) {
+ sb.append(", ");
+ }
+ profileCount++;
}
}
if(useIndent) {
@@ -413,9 +457,10 @@ public class GLProfile {
}
}
if(useIndent) {
+ doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+profileCount+" / "+allCount);
sb.append(Platform.getNewline());
} else {
- sb.append("]");
+ sb.append(", count "+profileCount+" / "+allCount+"]");
}
return sb;
@@ -1979,21 +2024,21 @@ public class GLProfile {
}
}
} else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) {
- return GL4bc;
+ return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT);
} else if(GL4.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) {
- return GL4;
+ return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE);
} else if(GL3bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) {
- return GL3bc;
+ return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT);
} else if(GL3.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) {
- return GL3;
+ return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE);
} else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) {
- return GL2;
+ return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT);
} else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) {
- return GLES3;
+ return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES);
} else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) {
- return GLES2;
+ return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES);
} else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) {
- return GLES1;
+ return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES);
}
return null;
}
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 911a4c2be..8542a799a 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -826,8 +826,11 @@ public abstract class GLContextImpl extends GLContext {
final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
final int[] reqMajorCTP = new int[] { 0, 0 };
- getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP);
+ GLContext.getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP);
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": createContextARB: Requested "+GLContext.getGLVersion(reqMajorCTP[0], 0, reqMajorCTP[0], null));
+ }
int _major[] = { 0 };
int _minor[] = { 0 };
int _ctp[] = { 0 };
@@ -835,9 +838,12 @@ public abstract class GLContextImpl extends GLContext {
if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1],
_major, _minor, _ctp)) {
_ctp[0] |= additionalCtxCreationFlags;
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": createContextARB: Mapped "+GLContext.getGLVersion(_major[0], _minor[0], _ctp[0], null));
+ }
_ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]);
if(0!=_ctx) {
- setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false);
+ setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false /* strictMatch */, false /* withinGLVersionsMapping */);
}
}
return _ctx;
@@ -857,67 +863,95 @@ public abstract class GLContextImpl extends GLContext {
// Even w/ PROFILE_ALIASING, try to use true core GL profiles
// ensuring proper user behavior across platforms due to different feature sets!
//
- if(!hasGL4) {
+ if( Platform.OSType.MACOS == Platform.getOSType() &&
+ Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 ) {
+ /**
+ * OSX 10.9 GLRendererQuirks.GL4NeedsGL3Request, quirk is added as usual @ setRendererQuirks(..)
+ */
+ if( !hasGL4 && !hasGL3 ) {
+ hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3
+ success |= hasGL3;
+ if( hasGL3 ) {
+ final boolean isHWAccel = 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions );
+ if( isHWAccel && ctxVersion.getMajor() >= 4 ) {
+ // Gotcha: Creating a '3.2' ctx delivers a >= 4 ctx.
+ GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
+ hasGL4 = true;
+ if(DEBUG) {
+ System.err.println("Quirk Triggerd: "+GLRendererQuirks.toString(GLRendererQuirks.GL4NeedsGL3Request)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber());
+ }
+ }
+ resetStates(false); // clean this context states, since creation was temporary
+ }
+ }
+ }
+ if( !hasGL4 ) {
hasGL4 = createContextARBMapVersionsAvailable(4, CTX_PROFILE_CORE); // GL4
success |= hasGL4;
- if(hasGL4) {
- // Map all lower compatible profiles: GL3
- GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
- if(PROFILE_ALIASING) {
- hasGL3 = true;
+ if( hasGL4 ) {
+ if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) {
+ // Map hw-accel GL4 to all lower core profiles: GL3
+ GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
+ if( PROFILE_ALIASING ) {
+ hasGL3 = true;
+ }
}
resetStates(false); // clean context states, since creation was temporary
}
}
- if(!hasGL3) {
+ if( !hasGL3 ) {
hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3
success |= hasGL3;
- if(hasGL3) {
+ if( hasGL3 ) {
resetStates(false); // clean this context states, since creation was temporary
}
}
- if(!hasGL4bc) {
+ if( !hasGL4bc ) {
hasGL4bc = createContextARBMapVersionsAvailable(4, CTX_PROFILE_COMPAT); // GL4bc
success |= hasGL4bc;
- if(hasGL4bc) {
- // Map all lower compatible profiles: GL3bc, GL2, GL4, GL3
- GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
- GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
- if(!hasGL4) {
+ if( hasGL4bc ) {
+ if( !hasGL4 ) { // last chance .. ignore hw-accel
GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
+ hasGL4 = true;
}
- if(!hasGL3) {
+ if( !hasGL3 ) { // last chance .. ignore hw-accel
GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
- }
- if(PROFILE_ALIASING) {
- hasGL3bc = true;
- hasGL2 = true;
- hasGL4 = true;
hasGL3 = true;
}
+ if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) {
+ // Map hw-accel GL4bc to all lower compatible profiles: GL3bc, GL2
+ GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
+ GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
+ if(PROFILE_ALIASING) {
+ hasGL3bc = true;
+ hasGL2 = true;
+ }
+ }
resetStates(false); // clean this context states, since creation was temporary
}
}
- if(!hasGL3bc) {
+ if( !hasGL3bc ) {
hasGL3bc = createContextARBMapVersionsAvailable(3, CTX_PROFILE_COMPAT); // GL3bc
success |= hasGL3bc;
- if(hasGL3bc) {
- // Map all lower compatible profiles: GL2 and GL3
- GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
- if(!hasGL3) {
+ if( hasGL3bc ) {
+ if(!hasGL3) { // last chance .. ignore hw-accel
GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
- }
- if(PROFILE_ALIASING) {
- hasGL2 = true;
hasGL3 = true;
}
+ if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) {
+ // Map hw-accel GL3bc to all lower compatible profiles: GL2
+ GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions);
+ if(PROFILE_ALIASING) {
+ hasGL2 = true;
+ }
+ }
resetStates(false); // clean this context states, since creation was temporary
}
}
- if(!hasGL2) {
+ if( !hasGL2 ) {
hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2
success |= hasGL2;
- if(hasGL2) {
+ if( hasGL2 ) {
resetStates(false); // clean this context states, since creation was temporary
}
}
@@ -1022,7 +1056,7 @@ public abstract class GLContextImpl extends GLContext {
_context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]);
if(0 != _context) {
- if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true) ) {
+ if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true /* strictMatch */, true /* withinGLVersionsMapping */) ) {
break;
} else {
destroyContextARBImpl(_context);
@@ -1291,14 +1325,15 @@ public abstract class GLContextImpl extends GLContext {
*
* @param force force the setting, even if is already being set.
* This might be useful if you change the OpenGL implementation.
- * @param major OpenGL major version
- * @param minor OpenGL minor version
- * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY}
- * @param strictMatch if <code>true</code> the ctx must
+ * @param major OpenGL major version
+ * @param minor OpenGL minor version
+ * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY}
+ * @param strictMatch if <code>true</code> the ctx must
* <ul>
* <li>be greater or equal than the requested <code>major.minor</code> version, and</li>
* <li>match the ctxProfileBits</li>
* </ul>, otherwise method aborts and returns <code>false</code>.
+ * @param withinGLVersionsMapping TODO
* @return returns <code>true</code> if successful, otherwise <code>false</code>. See <code>strictMatch</code>.
* If <code>false</code> is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc.
* @see #setContextVersion
@@ -1306,7 +1341,8 @@ public abstract class GLContextImpl extends GLContext {
* @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT
* @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT
*/
- protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictMatch) {
+ protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits,
+ boolean strictMatch, boolean withinGLVersionsMapping) {
if(null!=this.gl && null!=glProcAddressTable && !force) {
return true; // already done and not forced
}
@@ -1322,7 +1358,7 @@ public abstract class GLContextImpl extends GLContext {
final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration();
final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice();
-
+ final int reqMajor = major, reqMinor = minor, reqCtxProfileBits = ctxProfileBits;
{
final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings();
if( !initGLRendererAndGLVersionStringsOK ) {
@@ -1424,7 +1460,10 @@ public abstract class GLContextImpl extends GLContext {
return false;
}
if (DEBUG) {
- System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed);
+ System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification req "+
+ GLContext.getGLVersion(reqMajor, reqMinor, reqCtxProfileBits, null)+" -> has "+
+ GLContext.getGLVersion(major, minor, ctxProfileBits, null)+
+ ", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed);
}
if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2
@@ -1433,7 +1472,7 @@ public abstract class GLContextImpl extends GLContext {
final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion);
- setRendererQuirks(adevice, major, minor, ctxProfileBits, vendorVersion);
+ setRendererQuirks(adevice, reqMajor, reqMinor, reqCtxProfileBits, major, minor, ctxProfileBits, vendorVersion, withinGLVersionsMapping);
if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) {
if(DEBUG) {
@@ -1550,7 +1589,10 @@ public abstract class GLContextImpl extends GLContext {
return true;
}
- private final void setRendererQuirks(final AbstractGraphicsDevice adevice, int major, int minor, int ctp, final VersionNumberString vendorVersion) {
+ private final void setRendererQuirks(final AbstractGraphicsDevice adevice,
+ int reqMajor, int reqMinor, int reqCTP,
+ int major, int minor, int ctp, final VersionNumberString vendorVersion,
+ boolean withinGLVersionsMapping) {
int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport )
int i = 0;
@@ -1577,7 +1619,17 @@ public abstract class GLContextImpl extends GLContext {
}
quirks[i++] = quirk;
}
-
+ if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 && 3==reqMajor && 4==major ) {
+ final int quirk = GLRendererQuirks.GL4NeedsGL3Request;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", req "+reqMajor+"."+reqMinor);
+ }
+ quirks[i++] = quirk;
+ if( withinGLVersionsMapping ) {
+ // Thread safe due to single threaded initialization!
+ GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1);
+ }
+ }
if( isDriverNVIDIAGeForce ) {
final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush
if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 ) {
@@ -1587,8 +1639,7 @@ public abstract class GLContextImpl extends GLContext {
}
quirks[i++] = quirk;
}
- final VersionNumber osxVersionNVGLSLGood = new VersionNumber(10,7,0); // < OSX 10.7.0 w/ NV has instable GLSL
- if( Platform.getOSVersionNumber().compareTo(osxVersionNVGLSLGood) < 0 ) {
+ if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Lion) < 0 ) { // < OSX 10.7.0 w/ NV has unstable GLSL
final int quirk = GLRendererQuirks.GLSLNonCompliant;
if(DEBUG) {
System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer);
@@ -1732,6 +1783,11 @@ public abstract class GLContextImpl extends GLContext {
}
glRendererQuirks = new GLRendererQuirks(quirks, 0, i);
+ GLRendererQuirks.pushStickyDeviceQuirks(adevice, glRendererQuirks); // Thread safe due to single threaded initialization!
+ if(DEBUG) {
+ System.err.println("Quirks local: "+glRendererQuirks);
+ System.err.println("Quirks sticky on "+adevice+": "+GLRendererQuirks.getStickyDeviceQuirks(adevice));
+ }
}
private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) {
@@ -1785,7 +1841,7 @@ public abstract class GLContextImpl extends GLContext {
if(!drawable.getChosenGLCapabilities().getHardwareAccelerated()) {
isHardwareRasterizer = false;
} else {
- isHardwareRasterizer = ! ( glRendererLowerCase.contains("software") /* Mesa3D */ ||
+ isHardwareRasterizer = ! ( glRendererLowerCase.contains("software") /* Mesa3D, Apple */ ||
glRendererLowerCase.contains("mesa x11") /* Mesa3D */ ||
glRendererLowerCase.contains("softpipe") /* Gallium */ ||
glRendererLowerCase.contains("llvmpipe") /* Gallium */
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 3de910369..d8bb2e9eb 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -222,7 +222,9 @@ public class EGLContext extends GLContextImpl {
throw new GLException("Error making context " +
toHexString(contextHandle) + " current: error code " + toHexString(EGL.eglGetError()));
}
- return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, contextVersionReq>=3); // strict match for es >= 3
+ return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES,
+ contextVersionReq>=3 /* strictMatch */, // strict match for es >= 3
+ false /* withinGLVersionsMapping */);
}
@Override
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java
index 4685e8bf1..d54a80ae3 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java
@@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext {
public EGLExternalContext(AbstractGraphicsScreen screen) {
super(null, null);
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index 31fa14fbb..54510b51a 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -416,7 +416,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if(aCap.getVisualID(VIDType.NATIVE) != nativeVisualID) {
if(DEBUG) { System.err.println("Remove["+i+"] (mismatch VisualID): "+aCap); }
removedCaps.add(availableCaps.remove(i));
- } if( 0 == aCap.getDepthBits() && 0 < capsChosen.getDepthBits() ) {
+ } else if( 0 == aCap.getDepthBits() && 0 < capsChosen.getDepthBits() ) {
// Hack for HiSilicon/Vivante/Immersion.16 Renderer ..
if(DEBUG) { System.err.println("Remove["+i+"] (mismatch depth-bits): "+aCap); }
removedCaps.add(availableCaps.remove(i));
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 03aae3f78..037aaca08 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -98,11 +98,13 @@ public class MacOSXCGLContext extends GLContextImpl
/* package */ static final boolean isTigerOrLater;
/* package */ static final boolean isLionOrLater;
+ /* package */ static final boolean isMavericksOrLater;
static {
final VersionNumber osvn = Platform.getOSVersionNumber();
- isTigerOrLater = osvn.getMajor() > 10 || ( osvn.getMajor() == 10 && osvn.getMinor() >= 4 );
- isLionOrLater = osvn.getMajor() > 10 || ( osvn.getMajor() == 10 && osvn.getMinor() >= 7 );
+ isTigerOrLater = osvn.compareTo(Platform.OSXVersion.Tiger) >= 0;
+ isLionOrLater = osvn.compareTo(Platform.OSXVersion.Lion) >= 0;
+ isMavericksOrLater = osvn.compareTo(Platform.OSXVersion.Mavericks) >= 0;
}
static boolean isGLProfileSupported(int ctp, int major, int minor) {
@@ -110,30 +112,45 @@ public class MacOSXCGLContext extends GLContextImpl
boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ;
// We exclude 3.0, since we would map it's core to GL2. Hence we force mapping 2.1 to GL2
- if(3==major && 1<=minor && minor<=2) {
- // [3.1..3.2] -> GL3*
+ if( 3 < major || 3 == major && 1 <= minor ) {
+ if(ctBwdCompat || !ctCore) {
+ // No compatibility profile on OS X
+ // Only core is supported
+ return false;
+ }
if(!isLionOrLater) {
- // no GL3* on pre lion
+ // no GL Profile >= GL3 core on pre lion
return false;
}
- if(ctBwdCompat) {
- // no compatibility profile on OS X
+ if(3 < major && !isMavericksOrLater) {
+ // no GL Profile >= GL4 core on pre mavericks
return false;
}
- return ctCore;
- } else if(major<3) {
+ // [3.1..3.x] -> GL3
+ // [4.0..4.x] -> GL4
+ return true;
+ } else if( major < 3 ) {
// < 3.0 -> GL2
return true;
}
return false; // 3.0 && > 3.2
}
- static int GLProfile2CGLOGLProfileValue(int ctp, int major, int minor) {
+ static int GLProfile2CGLOGLProfileValue(AbstractGraphicsDevice device, int ctp, int major, int minor) {
if(!MacOSXCGLContext.isGLProfileSupported(ctp, major, minor)) {
throw new GLException("OpenGL profile not supported: "+getGLVersion(major, minor, ctp, "@GLProfile2CGLOGLProfileVersion"));
}
- boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ;
- if( major == 3 && minor >= 1 && ctCore ) {
- return CGL.kCGLOGLPVersion_3_2_Core;
+ final boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ;
+
+ if( major == 4 && ctCore ) {
+ if( GLRendererQuirks.existStickyDeviceQuirk(device, GLRendererQuirks.GL4NeedsGL3Request) ) {
+ // Thread safe GLRendererQuirks sticky access, since we are only interested of the result _after_ GL version mapping,
+ // i.e. after single threaded initialization!
+ return CGL.kCGLOGLPVersion_GL3_Core;
+ } else {
+ return CGL.kCGLOGLPVersion_GL4_Core;
+ }
+ } else if( major == 3 && minor >= 1 && ctCore ) {
+ return CGL.kCGLOGLPVersion_GL3_Core;
} else {
return CGL.kCGLOGLPVersion_Legacy;
}
@@ -283,7 +300,8 @@ public class MacOSXCGLContext extends GLContextImpl
MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration();
GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
GLProfile glp = capabilitiesChosen.getGLProfile();
- if(glp.isGLES1() || glp.isGLES2() || glp.isGL4() || glp.isGL3() && !isLionOrLater) {
+ if( glp.isGLES1() || glp.isGLES2() || glp.isGLES3() ||
+ ( glp.isGL3() && !isLionOrLater ) || ( glp.isGL4() && !isMavericksOrLater ) ) {
throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp);
}
@@ -589,7 +607,7 @@ public class MacOSXCGLContext extends GLContextImpl
} else {
targetCaps = chosenCaps;
}
- pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(targetCaps, ctp, major, minor);
+ pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(config.getScreen().getDevice(), targetCaps, ctp, major, minor);
}
if (pixelFormat == 0) {
if(DEBUG) {
@@ -617,7 +635,7 @@ public class MacOSXCGLContext extends GLContextImpl
screenVSyncTimeout = 1000000 / sRefreshRate;
}
if(DEBUG) {
- System.err.println("NS create OSX>=lion "+isLionOrLater);
+ System.err.println("NS create OSX>=lion "+isLionOrLater+", OSX>=mavericks "+isMavericksOrLater);
System.err.println("NS create incompleteView: "+incompleteView);
System.err.println("NS create backingLayerHost: "+backingLayerHost);
System.err.println("NS create share: "+share);
@@ -1117,9 +1135,10 @@ public class MacOSXCGLContext extends GLContextImpl
@Override
public long create(long share, int ctp, int major, int minor) {
long ctx = 0;
- MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration();
- GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
- long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor);
+ final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration();
+ final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
+ final long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(config.getScreen().getDevice(),
+ chosenCaps, ctp, major, minor);
if (pixelFormat == 0) {
throw new GLException("Unable to allocate pixel format with requested GLCapabilities");
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
index 13e249a58..481c0b94b 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
@@ -47,7 +47,6 @@ import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
@@ -89,7 +88,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration
CGL.NSOpenGLPFASampleBuffers,
CGL.NSOpenGLPFASamples });
- static IntBuffer GLCapabilities2NSAttribList(IntBuffer attrToken, GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
+ static IntBuffer GLCapabilities2NSAttribList(AbstractGraphicsDevice device, IntBuffer attrToken, GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
final int len = attrToken.remaining();
final int off = attrToken.position();
final IntBuffer ivalues = Buffers.newDirectIntBuffer(len);
@@ -98,7 +97,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration
final int attr = attrToken.get(idx+off);
switch (attr) {
case CGL.kCGLPFAOpenGLProfile:
- ivalues.put(idx, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor));
+ ivalues.put(idx, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(device, ctp, major, minor));
break;
case CGL.NSOpenGLPFANoRecovery:
ivalues.put(idx, caps.getHardwareAccelerated() ? 1 : 0);
@@ -156,13 +155,13 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration
return ivalues;
}
- static long GLCapabilities2NSPixelFormat(GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
+ static long GLCapabilities2NSPixelFormat(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
final IntBuffer attrToken = cglInternalAttributeToken.duplicate();
if ( !MacOSXCGLContext.isLionOrLater ) {
// no OpenGLProfile
attrToken.position(1);
}
- final IntBuffer ivalues = GLCapabilities2NSAttribList(attrToken, caps, ctp, major, minor);
+ final IntBuffer ivalues = GLCapabilities2NSAttribList(device, attrToken, caps, ctp, major, minor);
return CGL.createPixelFormat(attrToken, attrToken.remaining(), ivalues);
}
@@ -170,13 +169,13 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration
return PixelFormat2GLCapabilities(glp, pixelFormat, true);
}
- static long GLCapabilities2CGLPixelFormat(GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
+ static long GLCapabilities2CGLPixelFormat(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, int ctp, int major, int minor) {
// Set up pixel format attributes
final IntBuffer attrs = Buffers.newDirectIntBuffer(256);
int i = 0;
if(MacOSXCGLContext.isLionOrLater) {
attrs.put(i++, CGL.kCGLPFAOpenGLProfile);
- attrs.put(i++, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor));
+ attrs.put(i++, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(device, ctp, major, minor));
}
/**
if(!caps.isOnscreen() && caps.isPBuffer()) {
@@ -261,7 +260,10 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration
final int ivalue = ivalues.get(i);
if(CGL.kCGLPFAOpenGLProfile == attrToken.get(i+off)) {
switch(ivalue) {
- case CGL.kCGLOGLPVersion_3_2_Core:
+ case CGL.kCGLOGLPVersion_GL4_Core:
+ glp = GLProfile.get(GLProfile.GL4);
+ break;
+ case CGL.kCGLOGLPVersion_GL3_Core:
glp = GLProfile.get(GLProfile.GL3);
break;
case CGL.kCGLOGLPVersion_Legacy:
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
index d23d8a7e1..a2cf334ce 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -63,7 +63,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext {
setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL );
this.contextHandle = handle;
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
index 966a8b28a..95d7d8b82 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
@@ -64,7 +64,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext {
System.err.println(getThreadName() + ": Created external OpenGL context " + toHexString(ctx) + " for " + this);
}
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index d936308af..82be3e2b9 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -325,7 +325,7 @@ public class WindowsWGLContext extends GLContextImpl {
if ( !WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx) ) {
throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError());
}
- setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
WGL.wglMakeCurrent(0, 0); // release temp context
if( !createContextARBTried ) {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
index ba88ff3c4..a04d1989d 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
@@ -63,7 +63,7 @@ public class X11ExternalGLXContext extends X11GLXContext {
super(drawable, null);
this.contextHandle = ctx;
GLContextShareSet.contextCreated(this);
- setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false);
+ setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
getGLStateTracker().setEnabled(false); // external context usage can't track state in Java
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
index 22a48e093..42bb6b964 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java
@@ -320,7 +320,7 @@ public class X11GLXContext extends GLContextImpl {
if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) {
throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable);
}
- setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
isDirect = GLX.glXIsDirect(display, contextHandle);
if (DEBUG) {
System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct);
@@ -350,7 +350,7 @@ public class X11GLXContext extends GLContextImpl {
if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx) ) {
throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable);
}
- setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION
glXMakeContextCurrent(display, 0, 0, 0); // release temp context
if( !createContextARBTried ) {
// is*Available calls are valid since setGLFunctionAvailability(..) was called
diff --git a/src/jogl/native/macosx/MacOSXCustomCGLCode.c b/src/jogl/native/macosx/MacOSXCustomCGLCode.c
index f8b7a800f..75896c3a2 100644
--- a/src/jogl/native/macosx/MacOSXCustomCGLCode.c
+++ b/src/jogl/native/macosx/MacOSXCustomCGLCode.c
@@ -2,7 +2,7 @@
#include <assert.h>
-#include </usr/include/machine/types.h>
+#include <machine/types.h>
#include "macosx-window-system.h"
void CGLQueryPixelFormat(CGLPixelFormatObj fmt, int* iattrs, int niattrs, int* ivalues) {
diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
index 600aa6cb2..8d46d805a 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java
@@ -54,6 +54,7 @@ import javax.media.nativewindow.util.Point;
import com.jogamp.nativewindow.awt.JAWTWindow;
+import jogamp.nativewindow.Debug;
import jogamp.nativewindow.awt.AWTMisc;
import jogamp.nativewindow.jawt.JAWT;
import jogamp.nativewindow.jawt.JAWTFactory;
@@ -64,6 +65,14 @@ import jogamp.nativewindow.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo;
import jogamp.nativewindow.macosx.OSXUtil;
public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
+ /** May lead to deadlock, due to AWT pos comparison .. don't enable for Applets! */
+ private static final boolean DEBUG_CALAYER_POS_CRITICAL;
+
+ static {
+ Debug.initSingleton();
+ DEBUG_CALAYER_POS_CRITICAL = Debug.isPropertyDefined("nativewindow.debug.JAWT.OSXCALayerPos", true /* jnlpAlias */);
+ }
+
public MacOSXJAWTWindow(Object comp, AbstractGraphicsConfiguration config) {
super(comp, config);
if(DEBUG) {
@@ -122,7 +131,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
p1.translate(-outterInsets.left, -outterInsets.top);
}
- if( DEBUG ) {
+ if( DEBUG_CALAYER_POS_CRITICAL ) {
final java.awt.Point pA0 = component.getLocationOnScreen();
final Point pA1 = new Point(pA0.x, pA0.y);
pA1.translate(-outterComp.getX(), -outterComp.getY());
@@ -131,6 +140,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
}
System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+
", p0 "+p0+" -> "+p1+", bounds "+bounds);
+ } else if( DEBUG ) {
+ System.err.println("JAWTWindow.attachSurfaceLayerImpl: "+toHexString(layerHandle) + ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds);
}
OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p1.getX(), p1.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks());
} } );
@@ -152,7 +163,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
p1.translate(-outterInsets.left, -outterInsets.top);
}
- if( DEBUG ) {
+ if( DEBUG_CALAYER_POS_CRITICAL ) {
final java.awt.Point pA0 = component.getLocationOnScreen();
final Point pA1 = new Point(pA0.x, pA0.y);
pA1.translate(-outterComp.getX(), -outterComp.getY());
@@ -162,6 +173,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface {
System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", quirks "+caLayerQuirks+", visible "+visible+
", [ins "+outterInsets+"], pA "+pA0+" -> "+pA1+
", p0 "+p0+" -> "+p1+", bounds "+bounds);
+ } else if( DEBUG ) {
+ System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", quirks "+caLayerQuirks+", visible "+visible+
+ ", [ins "+outterInsets+"], p0 "+p0+" -> "+p1+", bounds "+bounds);
}
OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, visible, p1.getX(), p1.getY(), getWidth(), getHeight(), caLayerQuirks);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java
index 55328f1e6..29b48fecd 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java
@@ -41,8 +41,7 @@ import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -67,7 +66,7 @@ import com.jogamp.opengl.util.GLBuffers;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug692GL3VAO extends UITestCase {
static long duration = 500; // ms
-
+
static class GL3VAODemo implements GLEventListener {
/** Different modes of displaying the geometry */
public enum Mode {
@@ -78,7 +77,7 @@ public class TestBug692GL3VAO extends UITestCase {
t.displayNonVAO(gl);
}
},
-
+
/** Using VAOs throws [incorrectly as of JOGL 2.0rc11] a GLException */
VAO_NORMAL {
@Override
@@ -86,34 +85,34 @@ public class TestBug692GL3VAO extends UITestCase {
t.displayVAONormal(gl);
}
};
-
+
abstract void display(GL3VAODemo t, GL3 gl);
}
-
+
private final Mode[] allModes;
private Mode currentMode;
- private int currentModeIdx;
-
+ private int currentModeIdx;
+
public GL3VAODemo(Mode[] modes) {
allModes = modes;
currentMode = allModes[0];
currentModeIdx = 0;
}
-
+
private final static float[] vertexData = new float[]{
0.0f, 0.75f, 0.0f, 1,0,0,
-0.5f, -0.75f, 0.0f, 0,1,0,
0.9f, -0.75f, 0.0f, 0,0,1
};
-
+
private int ibo = -1;
private int vbo = -1;
private int vertID = -1;
private int fragID = -1;
private int progID = -1;
-
+
private int vaoNormal = -1;
-
+
private static int createShader(final GL3 gl, int type,
final String[] srcLines){
int shaderID = gl.glCreateShader(type);
@@ -126,14 +125,14 @@ public class TestBug692GL3VAO extends UITestCase {
gl.glCompileShader(shaderID);
return shaderID;
}
-
+
private void initBuffers(GL3 gl) {
// IDs for 2 buffers
int[] buffArray = new int[2];
gl.glGenBuffers(buffArray.length, buffArray, 0);
vbo = buffArray[0];
assert vbo > 0;
-
+
// Bind buffer and upload data
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo);
FloatBuffer buffer = GLBuffers.newDirectFloatBuffer(vertexData);
@@ -141,7 +140,7 @@ public class TestBug692GL3VAO extends UITestCase {
gl.glBufferData(GL3.GL_ARRAY_BUFFER, vertexData.length * Buffers.SIZEOF_FLOAT,
buffer, GL3.GL_STATIC_DRAW);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
-
+
// Buffer with the 3 indices required for one triangle
ibo = buffArray[1];
assert ibo > 0;
@@ -165,7 +164,7 @@ public class TestBug692GL3VAO extends UITestCase {
"}\n"
};
vertID = createShader(gl, GL3.GL_VERTEX_SHADER, vertSrc);
-
+
final String[] fragSrc = new String[]{
"#version 150\n",
"in vec4 pColor;\n",
@@ -174,10 +173,10 @@ public class TestBug692GL3VAO extends UITestCase {
"}\n"
};
fragID = createShader(gl, GL3.GL_FRAGMENT_SHADER, fragSrc);
-
+
// We're done with the compiler
gl.glReleaseShaderCompiler();
-
+
progID = gl.glCreateProgram();
assert progID > 0;
gl.glAttachShader(progID, vertID);
@@ -185,50 +184,50 @@ public class TestBug692GL3VAO extends UITestCase {
gl.glLinkProgram(progID);
gl.glValidateProgram(progID);
}
-
+
private int initVAO(GL3 gl) {
int[] buff = new int[1];
gl.glGenVertexArrays(1, buff, 0);
int vao = buff[0];
Assert.assertTrue("Invalid VAO: "+vao, vao > 0);
-
-
+
+
gl.glUseProgram(progID);
final int posLoc = gl.glGetAttribLocation(progID, "vPosition");
final int colorLoc = gl.glGetAttribLocation(progID, "vColor");
gl.glUseProgram(0);
-
+
gl.glBindVertexArray(vao);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo);
gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo);
-
+
gl.glEnableVertexAttribArray(posLoc);
gl.glEnableVertexAttribArray(colorLoc);
-
+
final int stride = 6 * Buffers.SIZEOF_FLOAT;
final int cOff = 3 * Buffers.SIZEOF_FLOAT;
gl.glVertexAttribPointer(posLoc, 3, GL3.GL_FLOAT, false, stride, 0L);
gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, cOff);
-
+
gl.glBindVertexArray(0);
return vao;
}
-
+
@Override
public void init(GLAutoDrawable drawable) {
drawable.setGL(new DebugGL3(drawable.getGL().getGL3()));
-
+
final GL3 gl = drawable.getGL().getGL3();
gl.glEnable(GL3.GL_DEPTH_TEST);
gl.glDisable(GL3.GL_CULL_FACE);
initBuffers(gl);
initShaders(gl);
-
+
vaoNormal = initVAO(gl);
-
+
gl.setSwapInterval(1);
}
-
+
@Override
public void dispose(GLAutoDrawable drawable) {
final GL3 gl = drawable.getGL().getGL3();
@@ -239,13 +238,13 @@ public class TestBug692GL3VAO extends UITestCase {
gl.glDeleteShader(fragID);
gl.glDeleteShader(vertID);
}
-
+
private void displayNonVAO(final GL3 gl) {
final int posLoc = gl.glGetAttribLocation(progID, "vPosition");
final int colorLoc = gl.glGetAttribLocation(progID, "vColor");
gl.glEnableVertexAttribArray(posLoc);
gl.glEnableVertexAttribArray(colorLoc);
-
+
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo);
final int stride = 6 * Buffers.SIZEOF_FLOAT;
final int cOff = 3 * Buffers.SIZEOF_FLOAT;
@@ -253,13 +252,13 @@ public class TestBug692GL3VAO extends UITestCase {
gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, cOff);
gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo);
gl.glDrawElements(GL3.GL_TRIANGLES, 3, GL3.GL_UNSIGNED_SHORT, 0L);
-
+
gl.glDisableVertexAttribArray(posLoc);
gl.glDisableVertexAttribArray(colorLoc);
gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0);
}
-
+
private void displayVAONormal(final GL3 gl) {
try {
gl.glBindVertexArray(vaoNormal);
@@ -269,7 +268,7 @@ public class TestBug692GL3VAO extends UITestCase {
Logger.getLogger(TestBug692GL3VAO.class.getName()).log(Level.SEVERE,null,ex);
}
}
-
+
@Override
public void display(GLAutoDrawable drawable) {
final GL3 gl = drawable.getGL().getGL3();
@@ -279,7 +278,7 @@ public class TestBug692GL3VAO extends UITestCase {
gl.glUseProgram(progID);
final Mode newMode;
{
- currentModeIdx = ( currentModeIdx + 1 ) % allModes.length;
+ currentModeIdx = ( currentModeIdx + 1 ) % allModes.length;
newMode = allModes[ currentModeIdx ];
}
if (newMode != currentMode) {
@@ -289,59 +288,59 @@ public class TestBug692GL3VAO extends UITestCase {
currentMode.display(this, gl);
gl.glUseProgram(0);
}
-
+
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
- }
+ }
}
-
+
private void testImpl(GLProfile profile, GL3VAODemo.Mode[] modes) throws InterruptedException {
final GLCapabilities capabilities = new GLCapabilities(profile);
final GLWindow glWindow = GLWindow.create(capabilities);
glWindow.setSize(512, 512);
-
+
Animator anim = new Animator(glWindow);
-
+
QuitAdapter quitAdapter = new QuitAdapter();
glWindow.addKeyListener(quitAdapter);
glWindow.addWindowListener(quitAdapter);
-
+
final GL3VAODemo vaoTest = new GL3VAODemo(modes);
glWindow.addGLEventListener(vaoTest);
glWindow.setVisible(true);
anim.start();
-
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
while(!quitAdapter.shouldQuit() && t1-t0<duration) {
Thread.sleep(100);
t1 = System.currentTimeMillis();
}
-
+
anim.stop();
glWindow.destroy();
}
-
+
//@Test
public void testGL3() throws GLException, InterruptedException {
if( ! GLProfile.isAvailable(GLProfile.GL3) ) {
System.err.println("GL3 n/a");
return;
}
- GL3VAODemo.Mode[] modes = new GL3VAODemo.Mode[] { GL3VAODemo.Mode.VAO_NORMAL };
- testImpl(GLProfile.get(GLProfile.GL3), modes);
+ GL3VAODemo.Mode[] modes = new GL3VAODemo.Mode[] { GL3VAODemo.Mode.VAO_NORMAL };
+ testImpl(GLProfile.get(GLProfile.GL3), modes);
}
-
+
@Test
public void testGL3bc() throws GLException, InterruptedException {
if( ! GLProfile.isAvailable(GLProfile.GL3bc) ) {
System.err.println("GL3bc n/a");
return;
}
- GL3VAODemo.Mode[] modes = new GL3VAODemo.Mode[] { GL3VAODemo.Mode.VAO_NORMAL, GL3VAODemo.Mode.NON_VAO };
- testImpl(GLProfile.get(GLProfile.GL3bc), modes);
+ GL3VAODemo.Mode[] modes = new GL3VAODemo.Mode[] { GL3VAODemo.Mode.VAO_NORMAL, GL3VAODemo.Mode.NON_VAO };
+ testImpl(GLProfile.get(GLProfile.GL3bc), modes);
}
-
+
public static void main(String args[]) throws IOException {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -350,6 +349,6 @@ public class TestBug692GL3VAO extends UITestCase {
}
String tstname = TestBug692GL3VAO.class.getName();
org.junit.runner.JUnitCore.main(tstname);
- }
-
+ }
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
index 7a48fbb2a..68562de4e 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,12 +20,12 @@
* 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 com.jogamp.opengl.test.junit.jogl.acore;
import java.io.IOException;
@@ -36,6 +36,7 @@ import org.junit.runners.MethodSorters;
import javax.media.opengl.*;
+import com.jogamp.opengl.JoglVersion;
import com.jogamp.opengl.test.junit.util.UITestCase;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -44,6 +45,7 @@ public class TestGLProfile00NEWT extends UITestCase {
@Test
public void testInitSingleton() throws InterruptedException {
GLProfile.initSingleton();
+ System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false));
}
public static void main(String args[]) throws IOException {
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java
index 763c0c8ff..234336016 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,12 +20,12 @@
* 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 com.jogamp.opengl.test.junit.jogl.awt;
import java.awt.Dimension;
@@ -38,8 +38,7 @@ import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.junit.FixMethodOrder;
@@ -55,14 +54,14 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestBug572AWT extends UITestCase {
static long durationPerTest = 150; // ms
-
+
static class Cleanup implements Runnable {
Window window;
-
+
public Cleanup(Window w) {
window = w;
}
-
+
public void run() {
System.err.println("cleaning up...");
window.setVisible(false);
@@ -75,10 +74,10 @@ public class TestBug572AWT extends UITestCase {
window.dispose();
}
}
-
+
private void testRealizeGLCanvas(final boolean onAWTEDT, final boolean setFrameSize) throws InterruptedException, InvocationTargetException {
final Window window = new JFrame(this.getSimpleTestName(" - "));
- final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+ final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
final GLCanvas glCanvas = new GLCanvas(caps);
final SnapshotGLEventListener snapshooter = new SnapshotGLEventListener();
snapshooter.setMakeSnapshotAlways(true);
@@ -95,7 +94,7 @@ public class TestBug572AWT extends UITestCase {
if( setFrameSize ) {
window.setSize(512, 512);
window.validate();
- } else {
+ } else {
Dimension size = new Dimension(512, 512);
glCanvas.setPreferredSize(size);
glCanvas.setMinimumSize(size);
@@ -109,42 +108,42 @@ public class TestBug572AWT extends UITestCase {
} else {
// trigger realization on non AWT-EDT, realization will happen at a later time ..
realizeAction.run();
-
+
// Wait until it's displayable after issuing initial setVisible(true) on current thread (non AWT-EDT)!
Assert.assertTrue("GLCanvas didn't become visible", AWTRobotUtil.waitForVisible(glCanvas, true));
- Assert.assertTrue("GLCanvas didn't become realized", AWTRobotUtil.waitForRealized(glCanvas, true)); // implies displayable
+ Assert.assertTrue("GLCanvas didn't become realized", AWTRobotUtil.waitForRealized(glCanvas, true)); // implies displayable
}
-
+
System.err.println("XXXX-0 "+glCanvas.getDelegatedDrawable().isRealized()+", "+glCanvas);
-
+
Assert.assertTrue("GLCanvas didn't become displayable", glCanvas.isDisplayable());
Assert.assertTrue("GLCanvas didn't become realized", glCanvas.isRealized());
-
+
// The AWT-EDT reshape/repaint events happen offthread later ..
System.err.println("XXXX-1 reshapeCount "+snapshooter.getReshapeCount());
System.err.println("XXXX-1 displayCount "+snapshooter.getDisplayCount());
-
+
// Wait unitl AWT-EDT has issued reshape/repaint
for (int wait=0; wait<AWTRobotUtil.POLL_DIVIDER &&
- ( 0 == snapshooter.getReshapeCount() || 0 == snapshooter.getDisplayCount() );
+ ( 0 == snapshooter.getReshapeCount() || 0 == snapshooter.getDisplayCount() );
wait++) {
Thread.sleep(AWTRobotUtil.TIME_SLICE);
}
System.err.println("XXXX-2 reshapeCount "+snapshooter.getReshapeCount());
System.err.println("XXXX-2 displayCount "+snapshooter.getDisplayCount());
-
+
Assert.assertTrue("GLCanvas didn't reshape", snapshooter.getReshapeCount()>0);
Assert.assertTrue("GLCanvas didn't display", snapshooter.getDisplayCount()>0);
-
+
Thread.sleep(durationPerTest);
-
+
// After initial 'setVisible(true)' all AWT manipulation needs to be done
// via the AWT EDT, according to the AWT spec.
// AWT / Swing on EDT..
SwingUtilities.invokeAndWait(new Cleanup(window));
}
-
+
@Test(timeout = 10000) // 10s timeout
public void test01RealizeGLCanvasOnAWTEDTUseFrameSize() throws InterruptedException, InvocationTargetException {
testRealizeGLCanvas(true, true);
@@ -154,7 +153,7 @@ public class TestBug572AWT extends UITestCase {
public void test02RealizeGLCanvasOnAWTEDTUseGLCanvasSize() throws InterruptedException, InvocationTargetException {
testRealizeGLCanvas(true, false);
}
-
+
@Test(timeout = 10000) // 10s timeout
public void test11RealizeGLCanvasOnMainTUseFrameSize() throws InterruptedException, InvocationTargetException {
testRealizeGLCanvas(false, true);
@@ -164,7 +163,7 @@ public class TestBug572AWT extends UITestCase {
public void test12RealizeGLCanvasOnMainTUseGLCanvasSize() throws InterruptedException, InvocationTargetException {
testRealizeGLCanvas(false, false);
}
-
+
public static void main(String args[]) {
org.junit.runner.JUnitCore.main(TestBug572AWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java
index 05f0c1ce3..3363fdd52 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,12 +20,12 @@
* 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 com.jogamp.opengl.test.junit.jogl.awt;
import java.awt.BorderLayout;
@@ -40,8 +40,7 @@ import javax.media.opengl.awt.GLCanvas;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -54,24 +53,24 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
public class TestBug675BeansInDesignTimeAWT extends UITestCase {
static boolean waitForKey = false;
static long durationPerTest = 200;
-
+
@Test
public void test01() throws InterruptedException, InvocationTargetException {
Beans.setDesignTime(true);
-
- final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
+
+ final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
final GLCanvas glCanvas = new GLCanvas(caps);
final Dimension preferredGLSize = new Dimension(400,200);
glCanvas.setPreferredSize(preferredGLSize);
glCanvas.setMinimumSize(preferredGLSize);
glCanvas.setSize(preferredGLSize);
-
+
glCanvas.addGLEventListener(new GearsES2());
final Window window = new JFrame(this.getSimpleTestName(" - "));
window.setLayout(new BorderLayout());
window.add(glCanvas, BorderLayout.CENTER);
-
+
// trigger realization on AWT-EDT, otherwise it won't immediatly ..
SwingUtilities.invokeAndWait(new Runnable() {
@Override
@@ -79,22 +78,22 @@ public class TestBug675BeansInDesignTimeAWT extends UITestCase {
window.pack();
window.validate();
window.setVisible(true);
- }
+ }
} );
-
+
// Immediately displayable after issuing initial setVisible(true) on AWT-EDT!
Assert.assertTrue("GLCanvas didn't become displayable", glCanvas.isDisplayable());
if( !Beans.isDesignTime() ) {
Assert.assertTrue("GLCanvas didn't become realized", glCanvas.isRealized());
}
-
+
Thread.sleep(durationPerTest);
-
+
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
window.dispose();
- }
+ }
} );
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
index 0b317eb84..89470a922 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,7 +20,7 @@
* 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.
@@ -45,8 +45,7 @@ import com.jogamp.opengl.util.texture.TextureIO;
import java.awt.image.BufferedImage;
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -58,19 +57,19 @@ public class TestBug605FlippedImageAWT extends UITestCase {
class FlippedImageTest implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
-
+
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT | GL2.GL_ACCUM_BUFFER_BIT );
-
+
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
-
+
// red below
gl.glColor3f(1, 0, 0);
gl.glRectf(-1, -1, 1, 0);
-
+
// green above
gl.glColor3f(0, 1, 0);
gl.glRectf(-1, 0, 1, 1);
@@ -80,12 +79,12 @@ public class TestBug605FlippedImageAWT extends UITestCase {
if(caps.getAccumGreenBits() > 0) {
gl.glAccum(GL2.GL_ACCUM, 1.0f);
gl.glAccum(GL2.GL_RETURN, 1.0f);
- }
+ }
gl.glFinish();
-
+
final int width = drawable.getWidth();
final int height = drawable.getHeight();
-
+
final String fname = getSnapshotFilename(0, null, caps, width, height, false, TextureIO.PNG, null);
try {
Screenshot.writeToFile(new File(fname), width, height, false);
@@ -93,83 +92,83 @@ public class TestBug605FlippedImageAWT extends UITestCase {
throw e;
} catch (IOException e) {
throw new GLException(e);
- }
+ }
testFlipped(width, height);
}
-
+
public void init(GLAutoDrawable drawable) {
final GL gl = drawable.getGL();
System.err.println("GL_RENDERER: "+gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: "+gl.glGetString(GL.GL_VERSION));
- }
- public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {}
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
+ }
+ public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {}
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
public void dispose(GLAutoDrawable drawable) {}
}
-
+
static final int green = 0x0000ff00; // above
static final int red = 0x00ff0000; // below
private void testFlipped(int width, int height) {
// Default origin 0/0 is lower left corner, so is the memory layout
- // However AWT origin 0/0 is upper left corner
+ // However AWT origin 0/0 is upper left corner
final BufferedImage image = Screenshot.readToBufferedImage(width, height);
-
+
final int below = image.getRGB(0, height-1) & 0x00ffffff;
System.err.println("below: 0x"+Integer.toHexString(below));
-
+
final int above = image.getRGB(0, 0) & 0x00ffffff;
System.err.println("above: 0x"+Integer.toHexString(above));
-
+
if (above == green && below == red) {
System.out.println("Image right side up");
} else if (above == red && below == green) {
Assert.assertTrue("Image is flipped", false);
} else {
Assert.assertTrue("Error in test", false);
- }
+ }
}
-
+
private void test(GLCapabilitiesImmutable caps) {
-
+
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile());
final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null);
final FlippedImageTest tglel = new FlippedImageTest();
glad.addGLEventListener(tglel);
-
+
// 1 frame incl. snapshot to memory & file
glad.display();
System.err.println("XXX "+glad.getChosenGLCapabilities());
System.err.println("XXX "+glad.getContext().getGLVersion());
-
- glad.destroy();
+
+ glad.destroy();
}
-
+
@Test
public void test01DefaultFBO() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
final GLCapabilities caps = new GLCapabilities(glp);
- caps.setFBO(true);
- test(caps);
+ caps.setFBO(true);
+ test(caps);
}
-
+
@Test
public void test01StencilFBO() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
final GLCapabilities caps = new GLCapabilities(glp);
caps.setStencilBits(8);
- caps.setFBO(true);
- test(caps);
+ caps.setFBO(true);
+ test(caps);
}
-
+
@Test
public void test01DefaultPBuffer() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
final GLCapabilities caps = new GLCapabilities(glp);
- caps.setPBuffer(true);
- test(caps);
+ caps.setPBuffer(true);
+ test(caps);
}
-
+
@Test
public void test01AccumStencilPBuffer() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
@@ -178,10 +177,10 @@ public class TestBug605FlippedImageAWT extends UITestCase {
caps.setAccumGreenBits(16);
caps.setAccumBlueBits(16);
caps.setStencilBits(8);
- caps.setPBuffer(true);
- test(caps);
+ caps.setPBuffer(true);
+ test(caps);
}
-
+
public static void main(String[] args) {
org.junit.runner.JUnitCore.main(TestBug605FlippedImageAWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
index 4fc681a74..8d4710ad3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,7 +20,7 @@
* 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.
@@ -38,8 +38,7 @@ import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
-import junit.framework.Assert;
-
+import org.junit.Assert;
import org.junit.Test;
import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@@ -52,71 +51,71 @@ public class TestBug605FlippedImageNEWT extends UITestCase {
static class FlippedImageTest implements GLEventListener {
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
-
+
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT | GL2.GL_ACCUM_BUFFER_BIT );
-
+
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
-
+
// red below
gl.glColor3f(1, 0, 0);
gl.glRectf(-1, -1, 1, 0);
-
+
// green above
gl.glColor3f(0, 1, 0);
gl.glRectf(-1, 0, 1, 1);
gl.glFinish();
-
+
final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities();
if(caps.getAccumGreenBits() > 0) {
gl.glAccum(GL2.GL_ACCUM, 1.0f);
gl.glAccum(GL2.GL_RETURN, 1.0f);
- }
+ }
gl.glFinish();
}
-
+
public void init(GLAutoDrawable drawable) {
final GL gl = drawable.getGL();
System.err.println("GL_RENDERER: "+gl.glGetString(GL.GL_RENDERER));
System.err.println("GL_VERSION: "+gl.glGetString(GL.GL_VERSION));
- }
- public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {}
- public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
+ }
+ public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {}
+ public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
public void dispose(GLAutoDrawable drawable) {}
}
-
+
static final int green = 0x0000ff00; // above
static final int red = 0x00ff0000; // below
private int getRGB(ByteBuffer bb, int o) {
- return ( (int)bb.get(o+0) & 0x000000ff ) << 16 |
- ( (int)bb.get(o+1) & 0x000000ff ) << 8 |
- ( (int)bb.get(o+2) & 0x000000ff );
+ return ( bb.get(o+0) & 0x000000ff ) << 16 |
+ ( bb.get(o+1) & 0x000000ff ) << 8 |
+ ( bb.get(o+2) & 0x000000ff );
}
-
+
private void testFlipped(ByteBuffer bb, int width, int height, int comp) {
// Default origin 0/0 is lower left corner, so is the memory layout
-
+
// x=0, y=0: RGB -> _RGB [high-byte .. low-byte]
final int below = getRGB(bb, 0);
System.err.println("below: 0x"+Integer.toHexString(below));
-
+
// x=0, y=height-1: RGB -> _RGB [high-byte .. low-byte]
final int above= getRGB(bb, ( height - 1 ) * ( width * comp ));
System.err.println("above: 0x"+Integer.toHexString(above));
-
+
if (above == green && below == red) {
System.out.println("Image right side up");
} else if (above == red && below == green) {
Assert.assertTrue("Image is flipped", false);
} else {
Assert.assertTrue("Error in test", false);
- }
+ }
}
-
+
private void test(GLCapabilitiesImmutable caps) {
final GLReadBufferUtil rbu = new GLReadBufferUtil(false, false);
final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile());
@@ -125,42 +124,42 @@ public class TestBug605FlippedImageNEWT extends UITestCase {
glad.addGLEventListener(tglel);
final SnapshotGLEventListener snap = new SnapshotGLEventListener(rbu);
glad.addGLEventListener(snap);
- snap.setMakeSnapshotAlways(true);
-
+ snap.setMakeSnapshotAlways(true);
+
// 1 frame incl. snapshot to memory & file
glad.display();
System.err.println("XXX "+glad.getChosenGLCapabilities());
System.err.println("XXX "+glad.getContext().getGLVersion());
- testFlipped((ByteBuffer)rbu.getPixelBuffer().buffer, glad.getWidth(), glad.getHeight(), 3);
-
- glad.destroy();
+ testFlipped((ByteBuffer)rbu.getPixelBuffer().buffer, glad.getWidth(), glad.getHeight(), 3);
+
+ glad.destroy();
}
-
+
@Test
public void test01DefaultFBO() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
final GLCapabilities caps = new GLCapabilities(glp);
- caps.setFBO(true);
- test(caps);
+ caps.setFBO(true);
+ test(caps);
}
-
+
@Test
public void test01StencilFBO() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
final GLCapabilities caps = new GLCapabilities(glp);
caps.setStencilBits(8);
- caps.setFBO(true);
- test(caps);
+ caps.setFBO(true);
+ test(caps);
}
-
+
@Test
public void test01DefaultPBuffer() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
final GLCapabilities caps = new GLCapabilities(glp);
- caps.setPBuffer(true);
- test(caps);
+ caps.setPBuffer(true);
+ test(caps);
}
-
+
@Test
public void test01AccumStencilPBuffer() {
final GLProfile glp = GLProfile.get(GLProfile.GL2);
@@ -169,10 +168,10 @@ public class TestBug605FlippedImageNEWT extends UITestCase {
caps.setAccumGreenBits(16);
caps.setAccumBlueBits(16);
caps.setStencilBits(8);
- caps.setPBuffer(true);
- test(caps);
+ caps.setPBuffer(true);
+ test(caps);
}
-
+
public static void main(String[] args) {
org.junit.runner.JUnitCore.main(TestBug605FlippedImageNEWT.class.getName());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index 74be176da..b54a2cd19 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,12 +20,12 @@
* 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 com.jogamp.opengl.test.junit.jogl.demos.es2.newt;
import java.io.IOException;
@@ -70,7 +70,7 @@ import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestGearsES2NEWT extends UITestCase {
+public class TestGearsES2NEWT extends UITestCase {
static int screenIdx = 0;
static PointImmutable wpos;
static DimensionImmutable wsize, rwsize=null;
@@ -92,12 +92,13 @@ public class TestGearsES2NEWT extends UITestCase {
static boolean forceES2 = false;
static boolean forceES3 = false;
static boolean forceGL3 = false;
+ static boolean forceGL2 = false;
static boolean mainRun = false;
static boolean exclusiveContext = false;
static boolean useAnimator = true;
static enum SysExit { none, testExit, testError, displayExit, displayError };
static SysExit sysExit = SysExit.none;
-
+
@BeforeClass
public static void initClass() {
if(null == wsize) {
@@ -129,7 +130,7 @@ public class TestGearsES2NEWT extends UITestCase {
final GearsES2 demo = new GearsES2(swapInterval);
demo.setPMVUseBackingArray(pmvUseBackingArray);
glWindow.addGLEventListener(demo);
-
+
final SnapshotGLEventListener snap = new SnapshotGLEventListener();
glWindow.addGLEventListener(snap);
if(waitForKey) {
@@ -154,7 +155,7 @@ public class TestGearsES2NEWT extends UITestCase {
animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD);
animator.setExclusiveContext(exclusiveContext);
}
-
+
QuitAdapter quitAdapter = new QuitAdapter();
//glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
//glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));
@@ -167,9 +168,9 @@ public class TestGearsES2NEWT extends UITestCase {
}
public void windowMoved(WindowEvent e) {
System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight());
- }
+ }
});
-
+
glWindow.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
@@ -299,7 +300,7 @@ public class TestGearsES2NEWT extends UITestCase {
throw new Error("test error send from GLEventListener");
} else if ( SysExit.displayExit == sysExit ) {
System.err.println("exit(0) send from GLEventListener");
- System.exit(0);
+ System.exit(0);
}
}
} else {
@@ -307,29 +308,29 @@ public class TestGearsES2NEWT extends UITestCase {
}
}
@Override
- public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
+ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { }
});
}
-
+
glWindow.setVisible(true);
if( useAnimator ) {
animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
}
-
+
System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities());
System.err.println("GL chosen: "+glWindow.getChosenCapabilities());
System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
-
+
snap.setMakeSnapshot();
if( null != rwsize ) {
- Thread.sleep(500); // 500ms delay
+ Thread.sleep(500); // 500ms delay
glWindow.setSize(rwsize.getWidth(), rwsize.getHeight());
System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets());
}
-
+
snap.setMakeSnapshot();
-
+
final long t0 = System.currentTimeMillis();
long t1 = t0;
while(!quitAdapter.shouldQuit() && t1-t0<duration) {
@@ -341,7 +342,7 @@ public class TestGearsES2NEWT extends UITestCase {
throw new Error("test error send from test thread");
} else if ( SysExit.testExit == sysExit ) {
System.err.println("exit(0) send from test thread");
- System.exit(0);
+ System.exit(0);
}
}
}
@@ -371,13 +372,15 @@ public class TestGearsES2NEWT extends UITestCase {
glp = GLProfile.get(GLProfile.GLES3);
} else if(forceES2) {
glp = GLProfile.get(GLProfile.GLES2);
+ } else if(forceGL2) {
+ glp = GLProfile.get(GLProfile.GL2);
} else {
glp = GLProfile.getGL2ES2();
}
final GLCapabilities caps = new GLCapabilities( glp );
caps.setBackgroundOpaque(opaque);
if(-1 < forceAlpha) {
- caps.setAlphaBits(forceAlpha);
+ caps.setAlphaBits(forceAlpha);
}
runTestGL(caps, undecorated);
if(loop_shutdown) {
@@ -389,7 +392,7 @@ public class TestGearsES2NEWT extends UITestCase {
@Test
public void test02_GLES2() throws InterruptedException {
if(mainRun) return;
-
+
if( !GLProfile.isAvailable(GLProfile.GLES2) ) {
System.err.println("GLES2 n/a");
return;
@@ -398,11 +401,11 @@ public class TestGearsES2NEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, undecorated);
}
-
+
@Test
public void test03_GL3() throws InterruptedException {
if(mainRun) return;
-
+
if( !GLProfile.isAvailable(GLProfile.GL3) ) {
System.err.println("GL3 n/a");
return;
@@ -411,13 +414,13 @@ public class TestGearsES2NEWT extends UITestCase {
final GLCapabilities caps = new GLCapabilities( glp );
runTestGL(caps, undecorated);
}
-
+
public static void main(String args[]) throws IOException {
mainRun = true;
-
+
int x=0, y=0, w=640, h=480, rw=-1, rh=-1;
boolean usePos = false;
-
+
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
i++;
@@ -448,6 +451,8 @@ public class TestGearsES2NEWT extends UITestCase {
forceES3 = true;
} else if(args[i].equals("-gl3")) {
forceGL3 = true;
+ } else if(args[i].equals("-gl2")) {
+ forceGL2 = true;
} else if(args[i].equals("-wait")) {
waitForKey = true;
} else if(args[i].equals("-mouseInvisible")) {
@@ -493,7 +498,7 @@ public class TestGearsES2NEWT extends UITestCase {
if( 0 < rw && 0 < rh ) {
rwsize = new Dimension(rw, rh);
}
-
+
if(usePos) {
wpos = new Point(x, y);
}
@@ -502,11 +507,11 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("resize "+rwsize);
System.err.println("screen "+screenIdx);
System.err.println("translucent "+(!opaque));
- System.err.println("forceAlpha "+forceAlpha);
+ System.err.println("forceAlpha "+forceAlpha);
System.err.println("undecorated "+undecorated);
System.err.println("atop "+alwaysOnTop);
System.err.println("fullscreen "+fullscreen);
- System.err.println("pmvDirect "+(!pmvUseBackingArray));
+ System.err.println("pmvDirect "+(!pmvUseBackingArray));
System.err.println("mouseVisible "+mouseVisible);
System.err.println("mouseConfined "+mouseConfined);
System.err.println("loops "+loops);
@@ -514,10 +519,11 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("forceES2 "+forceES2);
System.err.println("forceES3 "+forceES3);
System.err.println("forceGL3 "+forceGL3);
+ System.err.println("forceGL2 "+forceGL2);
System.err.println("swapInterval "+swapInterval);
System.err.println("exclusiveContext "+exclusiveContext);
System.err.println("useAnimator "+useAnimator);
- System.err.println("sysExitWithin "+sysExit);
+ System.err.println("sysExitWithin "+sysExit);
if(waitForKey) {
UITestCase.waitForKey("Start");
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
index dcb041147..87d4dafd6 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,7 +20,7 @@
* 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.
@@ -39,6 +39,8 @@ import org.eclipse.swt.layout.FillLayout ;
import org.eclipse.swt.widgets.Composite ;
import org.eclipse.swt.widgets.Display ;
import org.eclipse.swt.widgets.Shell ;
+
+import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.junit.FixMethodOrder;
@@ -51,8 +53,6 @@ import javax.media.opengl.GLCapabilities ;
import javax.media.opengl.GLEventListener ;
import javax.media.opengl.GLProfile;
-import junit.framework.Assert;
-
import com.jogamp.nativewindow.swt.SWTAccessor;
import com.jogamp.newt.NewtFactory;
import com.jogamp.newt.event.KeyAdapter;
@@ -68,63 +68,63 @@ import com.jogamp.opengl.test.junit.util.UITestCase;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
-
+
static int duration = 500;
-
+
static class BigFlashingX implements GLEventListener
- {
+ {
float r = 0f, g = 0f, b = 0f;
-
+
public void init( GLAutoDrawable drawable )
{
GL2 gl = drawable.getGL().getGL2() ;
-
+
gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ;
-
+
gl.glEnable( GL.GL_LINE_SMOOTH ) ;
gl.glEnable( GL.GL_BLEND ) ;
gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ) ;
}
-
+
public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height )
{
- // System.err.println( ">>>>>>>> reshape " + x + ", " + y + ", " + width + ", " +height ) ;
+ // System.err.println( ">>>>>>>> reshape " + x + ", " + y + ", " + width + ", " +height ) ;
GL2 gl = drawable.getGL().getGL2() ;
-
+
gl.glViewport( 0, 0, width, height ) ;
-
+
gl.glMatrixMode( GL2.GL_PROJECTION ) ;
gl.glLoadIdentity() ;
gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) ;
-
+
gl.glMatrixMode( GL2.GL_MODELVIEW ) ;
gl.glLoadIdentity() ;
}
-
+
public void display( GLAutoDrawable drawable )
{
- // System.err.println( ">>>> display" ) ;
+ // System.err.println( ">>>> display" ) ;
GL2 gl = drawable.getGL().getGL2() ;
-
+
// Sven: I could have been seeing things, but it seemed that if this
// glClear is in here twice it seems aggravates the problem. Not
// sure why other than it just takes longer, but this is pretty
// fast operation.
gl.glClear( GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT ) ;
gl.glClear( GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT ) ;
-
+
gl.glColor4f( r, g, b, 1.0f ) ;
-
+
gl.glBegin( GL.GL_LINES ) ;
{
gl.glVertex2f( -1.0f, 1.0f ) ;
gl.glVertex2f( 1.0f, -1.0f ) ;
-
+
gl.glVertex2f( -1.0f, -1.0f ) ;
gl.glVertex2f( 1.0f, 1.0f ) ;
}
gl.glEnd() ;
-
+
if(r<1f) {
r+=0.1f;
} else if(g<1f) {
@@ -137,25 +137,25 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
b = 0f;
}
}
-
+
public void dispose( GLAutoDrawable drawable )
{
}
}
-
+
////////////////////////////////////////////////////////////////////////////////
-
+
static class ResizeThread extends Thread {
volatile boolean shallStop = false;
- private Shell _shell ;
+ private final Shell _shell ;
private int _n ;
-
+
public ResizeThread( Shell shell )
{
super();
_shell = shell ;
}
-
+
final Runnable resizeAction = new Runnable() {
public void run()
{
@@ -172,10 +172,10 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
} catch (Exception e0) {
e0.printStackTrace();
Assert.assertTrue("Deadlock @ setSize: "+e0, false);
- }
+ }
++_n ;
} };
-
+
public void run()
{
// The problem was originally observed by grabbing the lower right
@@ -185,11 +185,11 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
//
// This loop simulates rapid resizing by the user by toggling
// the shell back-and-forth between two sizes.
-
+
System.err.println("[R-0 shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]");
-
+
final Display display = _shell.getDisplay();
-
+
while( !shallStop && !_shell.isDisposed() )
{
try
@@ -197,8 +197,8 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
System.err.println("[R-n shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]");
display.asyncExec( resizeAction );
display.wake();
-
- Thread.sleep( 50L ) ;
+
+ Thread.sleep( 50L ) ;
} catch( InterruptedException e ) {
break ;
}
@@ -206,26 +206,26 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+_shell.isDisposed());
}
}
-
+
////////////////////////////////////////////////////////////////////////////////
-
+
static class KeyfireThread extends Thread
{
volatile boolean shallStop = false;
Display _display;
Robot _robot;
int _n = 0;
-
+
public KeyfireThread(Robot robot, Display display)
{
_robot = robot;
_display = display;
}
-
+
public void run()
{
System.err.println("[K-0]");
-
+
while( !shallStop )
{
try {
@@ -245,26 +245,26 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
System.err.println("*K-Exit*");
}
}
-
+
////////////////////////////////////////////////////////////////////////////////
-
+
private volatile boolean shallStop = false;
-
+
static class SWT_DSC {
volatile Display display;
volatile Shell shell;
volatile Composite composite;
volatile com.jogamp.newt.Display swtNewtDisplay = null;
-
+
public void init() {
SWTAccessor.invoke(true, new Runnable() {
- public void run() {
+ public void run() {
display = new Display();
Assert.assertNotNull( display );
}});
-
+
display.syncExec(new Runnable() {
- public void run() {
+ public void run() {
shell = new Shell( display );
Assert.assertNotNull( shell );
shell.setLayout( new FillLayout() );
@@ -274,7 +274,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
}});
swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
}
-
+
public void dispose() {
Assert.assertNotNull( display );
Assert.assertNotNull( shell );
@@ -297,17 +297,17 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
swtNewtDisplay = null;
display = null;
shell = null;
- composite = null;
+ composite = null;
}
}
-
+
@Test
public void test() throws InterruptedException, AWTException, InvocationTargetException {
final Robot robot = new Robot();
-
+
final SWT_DSC dsc = new SWT_DSC();
dsc.init();
-
+
final GLWindow glWindow;
{
final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ;
@@ -320,38 +320,38 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
public void keyReleased(com.jogamp.newt.event.KeyEvent e) {
if( !e.isPrintableKey() || e.isAutoRepeat() ) {
return;
- }
+ }
System.err.print(".");
- glWindow.display();
- }
+ glWindow.display();
+ }
});
NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ;
}
-
+
dsc.display.syncExec( new Runnable() {
public void run() {
dsc.shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ;
dsc.shell.setSize( 400, 450 ) ;
dsc.shell.open() ;
} } );
-
+
AWTRobotUtil.requestFocus(robot, glWindow, false);
AWTRobotUtil.setMouseToClientLocation(robot, glWindow, 50, 50);
shallStop = false;
-
+
final ResizeThread resizer;
{
resizer = new ResizeThread( dsc.shell ) ;
resizer.start() ;
}
-
+
final KeyfireThread keyfire;
{
keyfire = new KeyfireThread( robot, dsc.display ) ;
keyfire.start() ;
}
-
+
{
final Thread t = new Thread(new Runnable() {
@Override
@@ -377,7 +377,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
t.setDaemon(true);
t.start();
}
-
+
try {
while( !shallStop && !dsc.display.isDisposed() ) {
dsc.display.syncExec( new Runnable() {
@@ -394,12 +394,12 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
e0.printStackTrace();
Assert.assertTrue("Deadlock @ dispatch: "+e0, false);
}
-
+
// canvas is disposed implicit, due to it's disposed listener !
-
+
dsc.dispose();
}
-
+
public static void main( String[] args ) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -407,7 +407,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase {
}
}
System.out.println("durationPerTest: "+duration);
- org.junit.runner.JUnitCore.main(TestNewtCanvasSWTBug628ResizeDeadlockAWT.class.getName());
+ org.junit.runner.JUnitCore.main(TestNewtCanvasSWTBug628ResizeDeadlockAWT.class.getName());
}
-
+
}
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java
index c9b832b8a..8b4e095f3 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java
@@ -3,14 +3,14 @@
*
* 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
@@ -20,7 +20,7 @@
* 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.
@@ -37,6 +37,8 @@ import org.eclipse.swt.layout.FillLayout ;
import org.eclipse.swt.widgets.Composite ;
import org.eclipse.swt.widgets.Display ;
import org.eclipse.swt.widgets.Shell ;
+
+import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
import org.junit.FixMethodOrder;
@@ -48,7 +50,6 @@ import javax.media.opengl.GLProfile;
import jogamp.newt.swt.SWTEDTUtil;
import jogamp.newt.swt.event.SWTNewtEventFactory;
-import junit.framework.Assert;
import com.jogamp.nativewindow.swt.SWTAccessor;
import com.jogamp.newt.NewtFactory;
@@ -66,12 +67,12 @@ import com.jogamp.opengl.util.Animator;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestSWTBug643AsyncExec extends UITestCase {
-
+
static int duration = 500;
static boolean useAnimator = false;
-
+
////////////////////////////////////////////////////////////////////////////////
-
+
static void resetSWTAndNEWTEDTCounter() {
synchronized(swtCountSync) {
swtCount=0;
@@ -103,43 +104,43 @@ public class TestSWTBug643AsyncExec extends UITestCase {
}
}
static Object swtCountSync = new Object();
- static int swtCount = 0;
+ static int swtCount = 0;
static Object edtCountSync = new Object();
- static int edtCount = 0;
-
+ static int edtCount = 0;
+
////////////////////////////////////////////////////////////////////////////////
-
+
static class AsyncExecEDTFeederThread extends Thread {
volatile boolean shallStop = false;
- private Display swtDisplay ;
- private jogamp.newt.DisplayImpl newtDisplay;
+ private final Display swtDisplay ;
+ private final jogamp.newt.DisplayImpl newtDisplay;
private int swtN, newtN ;
-
+
public AsyncExecEDTFeederThread( Display swtDisplay, com.jogamp.newt.Display newtDisplay )
{
super();
this.swtDisplay = swtDisplay ;
this.newtDisplay = (jogamp.newt.DisplayImpl)newtDisplay;
}
-
+
final Runnable swtAsyncAction = new Runnable() {
public void run()
{
++swtN ; incrSWTCount();
System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+getSWTCount()+"]");
} };
-
+
final Runnable newtAsyncAction = new Runnable() {
public void run()
{
++newtN ; incrNEWTCount();
System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+getNEWTCount()+"]");
} };
-
+
public void run()
{
System.err.println("[A-0 shallStop "+shallStop+"]");
-
+
while( !shallStop && !swtDisplay.isDisposed() )
{
try
@@ -151,7 +152,7 @@ public class TestSWTBug643AsyncExec extends UITestCase {
// only perform async exec on valid and already running NEWT EDT!
newtDisplay.runOnEDTIfAvail(false, newtAsyncAction);
}
- Thread.sleep( 50L ) ;
+ Thread.sleep( 50L ) ;
} catch( InterruptedException e ) {
break ;
}
@@ -159,34 +160,34 @@ public class TestSWTBug643AsyncExec extends UITestCase {
System.err.println("*R-Exit* shallStop "+shallStop);
}
}
-
+
////////////////////////////////////////////////////////////////////////////////
-
+
private volatile boolean shallStop = false;
-
+
static class SWT_DSC {
Display display;
Shell shell;
Composite composite;
-
+
public void init() {
SWTAccessor.invoke(true, new Runnable() {
- public void run() {
+ public void run() {
display = new Display();
Assert.assertNotNull( display );
}});
-
+
display.syncExec(new Runnable() {
- public void run() {
+ public void run() {
shell = new Shell( display );
Assert.assertNotNull( shell );
shell.setLayout( new FillLayout() );
composite = new Composite( shell, SWT.NO_BACKGROUND );
composite.setLayout( new FillLayout() );
Assert.assertNotNull( composite );
- }});
+ }});
}
-
+
public void dispose() {
Assert.assertNotNull( display );
Assert.assertNotNull( shell );
@@ -208,21 +209,21 @@ public class TestSWTBug643AsyncExec extends UITestCase {
}
display = null;
shell = null;
- composite = null;
+ composite = null;
}
}
-
+
private void testImpl(boolean useJOGLGLCanvas, boolean useNewtCanvasSWT, boolean glWindowPreVisible) throws InterruptedException, InvocationTargetException {
resetSWTAndNEWTEDTCounter();
-
+
final SWT_DSC dsc = new SWT_DSC();
dsc.init();
-
+
final com.jogamp.newt.Display newtDisplay;
{
final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ;
final GLCapabilities caps = new GLCapabilities( gl2Profile ) ;
-
+
final GLAutoDrawable glad;
if( useJOGLGLCanvas ) {
final GearsES2 demo = new GearsES2();
@@ -230,10 +231,10 @@ public class TestSWTBug643AsyncExec extends UITestCase {
final SWTNewtEventFactory swtNewtEventFactory = new SWTNewtEventFactory();
swtNewtEventFactory.attachDispatchListener(glc, glc, demo.gearsMouse, demo.gearsKeys);
glc.addGLEventListener( demo ) ;
- glad = glc;
- newtDisplay = null;
+ glad = glc;
+ newtDisplay = null;
} else if( useNewtCanvasSWT ) {
- newtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
+ newtDisplay = NewtFactory.createDisplay(null, false); // no-reuse
com.jogamp.newt.Screen screen = NewtFactory.createScreen(newtDisplay, 0);
final GLWindow glWindow = GLWindow.create( screen, caps ) ;
glWindow.addGLEventListener( new GearsES2() ) ;
@@ -241,10 +242,10 @@ public class TestSWTBug643AsyncExec extends UITestCase {
newtDisplay.setEDTUtil(new SWTEDTUtil(newtDisplay, dsc.display)); // Especially Windows requires creation access via same thread!
glWindow.setVisible(true);
AWTRobotUtil.waitForRealized(glWindow, true);
- Thread.sleep(120); // let it render a bit, before consumed by SWT
+ Thread.sleep(120); // let it render a bit, before consumed by SWT
}
glad = glWindow;
- NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ;
+ NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ;
} else {
throw new InternalError("XXX");
}
@@ -253,7 +254,7 @@ public class TestSWTBug643AsyncExec extends UITestCase {
animator.start();
}
}
-
+
System.err.println("**** Pre Shell Open");
dsc.display.syncExec( new Runnable() {
public void run() {
@@ -264,15 +265,15 @@ public class TestSWTBug643AsyncExec extends UITestCase {
System.err.println("**** Post Shell Open");
shallStop = false;
-
+
final int[] counterBeforeExit = new int[] { 0 /* SWT */, 0 /* NEWT */ };
-
+
final AsyncExecEDTFeederThread asyncExecFeeder;
{
asyncExecFeeder = new AsyncExecEDTFeederThread(dsc.display, newtDisplay) ;
asyncExecFeeder.start() ;
}
-
+
{
final Thread t = new Thread(new Runnable() {
@Override
@@ -280,7 +281,7 @@ public class TestSWTBug643AsyncExec extends UITestCase {
try {
Thread.sleep(duration);
} catch (InterruptedException e) {}
-
+
counterBeforeExit[0] = getSWTCount();
counterBeforeExit[1] = getNEWTCount();
asyncExecFeeder.shallStop = true;
@@ -294,9 +295,9 @@ public class TestSWTBug643AsyncExec extends UITestCase {
t.setDaemon(true);
t.start();
}
-
+
try {
- final Display d = dsc.display;
+ final Display d = dsc.display;
while( !shallStop && !d.isDisposed() ) {
if( !d.readAndDispatch() && !shallStop ) {
// blocks on linux .. dsc.display.sleep();
@@ -307,11 +308,11 @@ public class TestSWTBug643AsyncExec extends UITestCase {
e0.printStackTrace();
Assert.assertTrue("Deadlock @ dispatch: "+e0, false);
}
-
+
// canvas is disposed implicit, due to it's disposed listener !
-
+
dsc.dispose();
-
+
System.err.println("EDT Counter before exit: SWT " + counterBeforeExit[0] + ", NEWT "+counterBeforeExit[1]);
Assert.assertTrue("SWT EDT Counter not greater zero before dispose!", 0 < counterBeforeExit[0]);
if( null != newtDisplay ) {
@@ -323,17 +324,17 @@ public class TestSWTBug643AsyncExec extends UITestCase {
public void test01JOGLGLCanvas() throws InterruptedException, InvocationTargetException {
testImpl(true /* useJOGLGLCanvas */, false /* useNewtCanvasSWT */, false /* glWindowPreVisible */);
}
-
+
@Test
public void test02NewtCanvasSWTSimple() throws InterruptedException, InvocationTargetException {
testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */, false /* glWindowPreVisible */);
}
-
+
@Test
public void test02NewtCanvasSWTPreVisible() throws InterruptedException, InvocationTargetException {
testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */, true /* glWindowPreVisible */);
}
-
+
public static void main( String[] args ) {
for(int i=0; i<args.length; i++) {
if(args[i].equals("-time")) {
@@ -343,7 +344,7 @@ public class TestSWTBug643AsyncExec extends UITestCase {
}
}
System.out.println("durationPerTest: "+duration);
- org.junit.runner.JUnitCore.main(TestSWTBug643AsyncExec.class.getName());
+ org.junit.runner.JUnitCore.main(TestSWTBug643AsyncExec.class.getName());
}
-
+
}