aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/javax
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/javax')
-rw-r--r--src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java3
-rw-r--r--src/jogl/classes/javax/media/opengl/GLBase.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java87
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java12
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java52
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java62
6 files changed, 162 insertions, 66 deletions
diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
index 412af25e0..1991ad7d0 100644
--- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
+++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java
@@ -46,6 +46,7 @@ import java.util.List;
import javax.media.nativewindow.CapabilitiesImmutable;
+import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.util.PropertyAccess;
import jogamp.opengl.Debug;
@@ -126,7 +127,7 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser {
final int availnum = available.size();
if (DEBUG) {
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
System.err.println("Desired: " + gldes);
System.err.println("Available: " + availnum);
for (int i = 0; i < available.size(); i++) {
diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java
index 48455c525..802da3b6c 100644
--- a/src/jogl/classes/javax/media/opengl/GLBase.java
+++ b/src/jogl/classes/javax/media/opengl/GLBase.java
@@ -584,6 +584,9 @@ public interface GLBase {
/**
* Return the framebuffer name bound to this context,
* see {@link GL#glBindFramebuffer(int, int)}.
+ * <p>
+ * Calls {@link GLContext#getBoundFramebuffer(int)}.
+ * </p>
*/
public int getBoundFramebuffer(int target);
@@ -594,6 +597,9 @@ public interface GLBase {
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
* is being used.
* </p>
+ * <p>
+ * Calls {@link GLContext#getDefaultDrawFramebuffer()}.
+ * </p>
*/
public int getDefaultDrawFramebuffer();
@@ -604,6 +610,9 @@ public interface GLBase {
* in case an framebuffer object ({@link com.jogamp.opengl.FBObject}) based drawable
* is being used.
* </p>
+ * <p>
+ * Calls {@link GLContext#getDefaultReadFramebuffer()}.
+ * </p>
*/
public int getDefaultReadFramebuffer();
@@ -628,6 +637,9 @@ public interface GLBase {
* Note-3: See {@link com.jogamp.opengl.util.GLDrawableUtil#swapBuffersBeforeRead(GLCapabilitiesImmutable) swapBuffersBeforeRead}
* for read-pixels and swap-buffers implications.
* </p>
+ * <p>
+ * Calls {@link GLContext#getDefaultReadBuffer()}.
+ * </p>
*/
public int getDefaultReadBuffer();
}
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index e2498e6f1..01e0e8270 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -123,31 +123,43 @@ public abstract class GLContext {
public static final int CONTEXT_CURRENT_NEW = 2;
/** Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
- public static final VersionNumber Version100 = new VersionNumber(1, 0, 0);
+ public static final VersionNumber Version1_0 = new VersionNumber(1, 0, 0);
/** Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
- public static final VersionNumber Version110 = new VersionNumber(1, 10, 0);
+ public static final VersionNumber Version1_10 = new VersionNumber(1, 10, 0);
/** Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
- public static final VersionNumber Version120 = new VersionNumber(1, 20, 0);
+ public static final VersionNumber Version1_20 = new VersionNumber(1, 20, 0);
/** Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
- public static final VersionNumber Version130 = new VersionNumber(1, 30, 0);
+ public static final VersionNumber Version1_30 = new VersionNumber(1, 30, 0);
/** Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
- public static final VersionNumber Version140 = new VersionNumber(1, 40, 0);
+ public static final VersionNumber Version1_40 = new VersionNumber(1, 40, 0);
/** Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
- public static final VersionNumber Version150 = new VersionNumber(1, 50, 0);
+ public static final VersionNumber Version1_50 = new VersionNumber(1, 50, 0);
+
+ /** Version 1.1, i.e. GL 1.1 */
+ public static final VersionNumber Version1_1 = new VersionNumber(1, 1, 0);
+
+ /** Version 1.2, i.e. GL 1.2 */
+ public static final VersionNumber Version1_2 = new VersionNumber(1, 2, 0);
+
+ /** Version 1.4, i.e. GL 1.4 */
+ public static final VersionNumber Version1_4 = new VersionNumber(1, 4, 0);
+
+ /** Version 1.5, i.e. GL 1.5 */
+ public static final VersionNumber Version1_5 = new VersionNumber(1, 5, 0);
/** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. Or GLSL 3.00 for ES 3.0. */
- public static final VersionNumber Version300 = new VersionNumber(3, 0, 0);
+ public static final VersionNumber Version3_0 = new VersionNumber(3, 0, 0);
/** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */
- public static final VersionNumber Version310 = new VersionNumber(3, 1, 0);
+ public static final VersionNumber Version3_1 = new VersionNumber(3, 1, 0);
/** Version 3.2. As an OpenGL version, it qualifies for geometry shader */
- public static final VersionNumber Version320 = new VersionNumber(3, 2, 0);
+ public static final VersionNumber Version3_2 = new VersionNumber(3, 2, 0);
/** Version 4.3. As an OpenGL version, it qualifies for <code>GL_ARB_ES3_compatibility</code> */
- public static final VersionNumber Version430 = new VersionNumber(4, 3, 0);
+ public static final VersionNumber Version4_3 = new VersionNumber(4, 3, 0);
- protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0);
+ protected static final VersionNumber Version8_0 = new VersionNumber(8, 0, 0);
private static final String S_EMPTY = "";
@@ -321,10 +333,11 @@ public abstract class GLContext {
* if the {@link #getGLReadDrawable() read-drawable} differs
* from the {@link #getGLDrawable() write-drawable}.
* Otherwise set both drawables, read and write.
- * @return The previous read/write drawable
+ * @return The previous read/write drawable if operation succeeds
*
- * @throws GLException in case <code>null</code> is being passed or
- * this context is made current on another thread.
+ * @throws GLException in case <code>null</code> is being passed,
+ * this context is made current on another thread
+ * or operation fails.
*
* @see #isGLReadDrawableAvailable()
* @see #setGLReadDrawable(GLDrawable)
@@ -844,11 +857,11 @@ public abstract class GLContext {
final int minor = ctxGLSLVersion.getMinor();
final String profileOpt;
if( isGLES() ) {
- profileOpt = ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : S_EMPTY;
+ profileOpt = ctxGLSLVersion.compareTo(Version3_0) >= 0 ? " es" : S_EMPTY;
} else if( isGLCoreProfile() ) {
- profileOpt = ctxGLSLVersion.compareTo(Version150) >= 0 ? " core" : S_EMPTY;
+ profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " core" : S_EMPTY;
} else if( isGLCompatibilityProfile() ) {
- profileOpt = ctxGLSLVersion.compareTo(Version150) >= 0 ? " compatibility" : S_EMPTY;
+ profileOpt = ctxGLSLVersion.compareTo(Version1_50) >= 0 ? " compatibility" : S_EMPTY;
} else {
throw new InternalError("Neither ES, Core nor Compat: "+this); // see validateProfileBits(..)
}
@@ -858,22 +871,22 @@ public abstract class GLContext {
protected static final VersionNumber getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions) {
if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) {
if( 3 == glMajorVersion ) {
- return Version300; // ES 3.0 -> GLSL 3.00
+ return Version3_0; // ES 3.0 -> GLSL 3.00
} else if( 2 == glMajorVersion ) {
- return Version100; // ES 2.0 -> GLSL 1.00
+ return Version1_0; // ES 2.0 -> GLSL 1.00
}
} else if( 1 == glMajorVersion ) {
- return Version110; // GL 1.x -> GLSL 1.10
+ return Version1_10; // GL 1.x -> GLSL 1.10
} else if( 2 == glMajorVersion ) {
switch ( glMinorVersion ) {
- case 0: return Version110; // GL 2.0 -> GLSL 1.10
- default: return Version120; // GL 2.1 -> GLSL 1.20
+ case 0: return Version1_10; // GL 2.0 -> GLSL 1.10
+ default: return Version1_20; // GL 2.1 -> GLSL 1.20
}
} else if( 3 == glMajorVersion && 2 >= glMinorVersion ) {
switch ( glMinorVersion ) {
- case 0: return Version130; // GL 3.0 -> GLSL 1.30
- case 1: return Version140; // GL 3.1 -> GLSL 1.40
- default: return Version150; // GL 3.2 -> GLSL 1.50
+ case 0: return Version1_30; // GL 3.0 -> GLSL 1.30
+ case 1: return Version1_40; // GL 3.1 -> GLSL 1.40
+ default: return Version1_50; // GL 3.2 -> GLSL 1.50
}
}
// The new default: GL >= 3.3, ES >= 3.0
@@ -1032,7 +1045,7 @@ public abstract class GLContext {
*/
public final boolean isGL3bc() {
return 0 != (ctxOptions & CTX_PROFILE_COMPAT) &&
- ctxVersion.compareTo(Version310) >= 0 ;
+ ctxVersion.compareTo(Version3_1) >= 0 ;
}
/**
@@ -1041,7 +1054,7 @@ public abstract class GLContext {
*/
public final boolean isGL3() {
return 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) &&
- ctxVersion.compareTo(Version310) >= 0 ;
+ ctxVersion.compareTo(Version3_1) >= 0 ;
}
/**
@@ -1049,7 +1062,7 @@ public abstract class GLContext {
*/
public final boolean isGL3core() {
return 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
- ctxVersion.compareTo(Version310) >= 0;
+ ctxVersion.compareTo(Version3_1) >= 0;
}
/**
@@ -1058,7 +1071,7 @@ public abstract class GLContext {
public final boolean isGLcore() {
return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ) ||
( 0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
- ctxVersion.compareTo(Version310) >= 0
+ ctxVersion.compareTo(Version3_1) >= 0
) ;
}
@@ -1106,7 +1119,7 @@ public abstract class GLContext {
return // ES 3.x not included, see above. ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) ||
( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) &&
0 != ( ctxOptions & CTX_PROFILE_CORE ) &&
- ctxVersion.compareTo(Version310) >= 0
+ ctxVersion.compareTo(Version3_1) >= 0
) ;
}
@@ -1461,13 +1474,13 @@ public abstract class GLContext {
/* 1.*/ { 0, 1, 2, 3, 4, 5 },
/* 2.*/ { 0, 1 },
/* 3.*/ { 0, 1, 2, 3 },
- /* 4.*/ { 0, 1, 2, 3, 4 } };
+ /* 4.*/ { 0, 1, 2, 3, 4, 5 } };
public static final int ES_VERSIONS[][] = {
/* 0.*/ { -1 },
/* 1.*/ { 0, 1 },
/* 2.*/ { 0 },
- /* 3.*/ { 0 } };
+ /* 3.*/ { 0, 1 } };
public static final int getMaxMajor(final int ctxProfile) {
return ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ? ES_VERSIONS.length-1 : GL_VERSIONS.length-1;
@@ -1626,11 +1639,15 @@ public abstract class GLContext {
}
}
- protected static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device) {
+ protected static void setAvailableGLVersionsSet(final AbstractGraphicsDevice device, final boolean set) {
synchronized ( deviceVersionsAvailableSet ) {
final String devKey = device.getUniqueID();
- if( null != deviceVersionsAvailableSet.put(devKey, devKey) ) {
- throw new InternalError("Already set: "+devKey);
+ if( set ) {
+ if( null != deviceVersionsAvailableSet.put(devKey, devKey) ) {
+ throw new InternalError("Already set: "+devKey);
+ }
+ } else {
+ deviceVersionsAvailableSet.remove(devKey);
}
if (DEBUG) {
System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey);
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index 71568ee76..dabd3531b 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -144,7 +144,7 @@ public abstract class GLDrawableFactory {
}
}
}
- if (null != factoryClassName) {
+ if (null != factoryClassName && !GLProfile.disableOpenGLDesktop) {
if (DEBUG || GLProfile.DEBUG) {
System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nwt+": "+factoryClassName);
}
@@ -387,13 +387,14 @@ public abstract class GLDrawableFactory {
* </p>
*
* @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+ * @param glp {@link GLProfile} to identify the device's {@link GLRendererQuirks}, maybe {@code null}
* @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
* @throws IllegalArgumentException if the quirk is out of range
- * @see #getRendererQuirks(AbstractGraphicsDevice)
+ * @see #getRendererQuirks(AbstractGraphicsDevice, GLProfile)
* @see GLRendererQuirks
*/
- public final boolean hasRendererQuirk(final AbstractGraphicsDevice device, final int quirk) {
- final GLRendererQuirks glrq = getRendererQuirks(device);
+ public final boolean hasRendererQuirk(final AbstractGraphicsDevice device, final GLProfile glp, final int quirk) {
+ final GLRendererQuirks glrq = getRendererQuirks(device, glp);
return null != glrq ? glrq.exist(quirk) : false;
}
@@ -407,10 +408,11 @@ public abstract class GLDrawableFactory {
* the result is always <code>null</code>.
* </p>
* @param device which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+ * @param glp {@link GLProfile} to identify the device's {@link GLRendererQuirks}, maybe {@code null}
* @see GLContext#getRendererQuirks()
* @see GLRendererQuirks
*/
- public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device);
+ public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device, final GLProfile glp);
/**
* Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index c7aaca5d3..7f29bb7dc 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -41,6 +41,7 @@ import jogamp.opengl.Debug;
import jogamp.opengl.GLDrawableFactoryImpl;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
+import com.jogamp.common.ExceptionUtils;
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.jvm.JNILibLoaderBase;
import com.jogamp.common.os.Platform;
@@ -52,6 +53,7 @@ import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveThreadGroupLock;
import com.jogamp.gluegen.runtime.FunctionAddressResolver;
import com.jogamp.nativewindow.NativeWindowVersion;
+import com.jogamp.opengl.GLRendererQuirks;
import com.jogamp.opengl.JoglVersion;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -79,13 +81,6 @@ public class GLProfile {
public static final boolean DEBUG;
/**
- * In case no OpenGL ES profiles are required
- * and if one platform may have a buggy implementation,
- * setting the property <code>jogl.disable.opengles</code> disables querying possible existing OpenGL ES profiles.
- */
- public static final boolean disableOpenGLES;
-
- /**
* In case no native OpenGL core profiles are required
* and if one platform may have a buggy implementation,
* setting the property <code>jogl.disable.openglcore</code> disables querying possible existing native OpenGL core profiles.
@@ -100,12 +95,43 @@ public class GLProfile {
* context creation extension is buggy on one platform,
* setting the property <code>jogl.disable.openglarbcontext</code> disables utilizing it.
* <p>
+ * This exclusion also disables {@link #disableOpenGLES OpenGL ES}.
+ * </p>
+ * <p>
* This exclusion is disabled for {@link Platform.OSType#MACOS}.
* </p>
*/
public static final boolean disableOpenGLARBContext;
/**
+ * In case no OpenGL ES profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property <code>jogl.disable.opengles</code> disables querying possible existing OpenGL ES profiles.
+ */
+ public static final boolean disableOpenGLES;
+
+ /**
+ * In case no OpenGL desktop profiles are required
+ * and if one platform may have a buggy implementation,
+ * setting the property <code>jogl.disable.opengldesktop</code> disables querying possible existing OpenGL desktop profiles.
+ */
+ public static final boolean disableOpenGLDesktop;
+
+ /**
+ * Disable surfaceless OpenGL context capability and its probing
+ * by setting the property <code>jogl.disable.surfacelesscontext</code>.
+ * <p>
+ * By default surfaceless OpenGL context capability is probed,
+ * i.e. whether an OpenGL context can be made current without a default framebuffer.
+ * </p>
+ * <p>
+ * If probing fails or if this property is set, the {@link GLRendererQuirks quirk} {@link GLRendererQuirks#NoSurfacelessCtx}
+ * is being set.
+ * </p>
+ */
+ public static final boolean disableSurfacelessContext;
+
+ /**
* We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome.
* When run in the mentioned browsers, the eglInitialize(..) implementation crashes.
* <p>
@@ -121,9 +147,11 @@ public class GLProfile {
final boolean isOSX = Platform.OSType.MACOS == Platform.getOSType();
DEBUG = Debug.debug("GLProfile");
- disableOpenGLES = PropertyAccess.isPropertyDefined("jogl.disable.opengles", true);
disableOpenGLCore = PropertyAccess.isPropertyDefined("jogl.disable.openglcore", true) && !isOSX;
disableOpenGLARBContext = PropertyAccess.isPropertyDefined("jogl.disable.openglarbcontext", true) && !isOSX;
+ disableOpenGLES = disableOpenGLARBContext || PropertyAccess.isPropertyDefined("jogl.disable.opengles", true);
+ disableOpenGLDesktop = PropertyAccess.isPropertyDefined("jogl.disable.opengldesktop", true);
+ disableSurfacelessContext = PropertyAccess.isPropertyDefined("jogl.disable.surfacelesscontext", true);
enableANGLE = PropertyAccess.isPropertyDefined("jogl.enable.ANGLE", true);
}
@@ -175,7 +203,7 @@ public class GLProfile {
justInitialized = true;
if(DEBUG) {
System.err.println("GLProfile.initSingleton() - thread "+Thread.currentThread().getName());
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
}
if(ReflectionUtil.DEBUG_STATS_FORNAME) {
@@ -246,7 +274,7 @@ public class GLProfile {
initialized = false;
if(DEBUG) {
System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName());
- Thread.dumpStack();
+ ExceptionUtils.dumpStack(System.err);
}
GLDrawableFactory.shutdown();
}
@@ -1894,7 +1922,7 @@ public class GLProfile {
// also test GLES1, GLES2 and GLES3 on desktop, since we have implementations / emulations available.
if( deviceIsEGLCompatible && ( hasGLES3Impl || hasGLES1Impl ) ) {
// 1st pretend we have all EGL profiles ..
- computeProfileMap(device, false /* desktopCtxUndef*/, true /* esCtxUndef */);
+ computeProfileMap(device, true /* desktopCtxUndef*/, true /* esCtxUndef */);
// Triggers eager initialization of share context in GLDrawableFactory for the device,
// hence querying all available GLProfiles
@@ -1934,7 +1962,7 @@ public class GLProfile {
}
if(!GLContext.getAvailableGLVersionsSet(device)) {
- GLContext.setAvailableGLVersionsSet(device);
+ GLContext.setAvailableGLVersionsSet(device, true);
}
if (DEBUG) {
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index 8d23d79ff..6e9e28c19 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -63,6 +63,7 @@ import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.ScalableSurface;
import javax.media.nativewindow.SurfaceUpdatedListener;
import javax.media.nativewindow.WindowClosingProtocol;
+import javax.media.nativewindow.util.PixelFormat;
import javax.media.opengl.GL;
import javax.media.opengl.GL2;
import javax.media.opengl.GL2ES3;
@@ -265,12 +266,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
private final int[] hasPixelScale = new int[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
private final int[] reqPixelScale = new int[] { ScalableSurface.AUTOMAX_PIXELSCALE, ScalableSurface.AUTOMAX_PIXELSCALE };
- // For handling reshape events lazily: reshapeWidth -> panelWidth -> backend.width
+ /** For handling reshape events lazily: reshapeWidth -> panelWidth -> backend.width in pixel units (scaled) */
private int reshapeWidth;
+ /** For handling reshape events lazily: reshapeHeight -> panelHeight -> backend.height in pixel units (scaled) */
private int reshapeHeight;
- // Width of the actual GLJPanel: reshapeWidth -> panelWidth -> backend.width
+ /** Scaled pixel width of the actual GLJPanel: reshapeWidth -> panelWidth -> backend.width */
private int panelWidth = 0;
+ /** Scaled pixel height of the actual GLJPanel: reshapeHeight -> panelHeight -> backend.height */
private int panelHeight = 0;
// These are always set to (0, 0) except when the Java2D / OpenGL
@@ -578,14 +581,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
@Override
public final void setSurfaceScale(final int[] pixelScale) { // HiDPI support
SurfaceScaleUtils.validateReqPixelScale(reqPixelScale, pixelScale, DEBUG ? getClass().getSimpleName() : null);
- final Backend b = backend;
- if ( isInitialized && null != b ) {
- final int hadPixelScaleX = hasPixelScale[0];
- final int hadPixelScaleY = hasPixelScale[1];
- SurfaceScaleUtils.computePixelScale(hasPixelScale, hasPixelScale, reqPixelScale, nativePixelScale, DEBUG ? getClass().getSimpleName() : null);
- if( hadPixelScaleX != hasPixelScale[0] || hadPixelScaleY != hasPixelScale[1] ) {
+ final int hadPixelScaleX = hasPixelScale[0];
+ final int hadPixelScaleY = hasPixelScale[1];
+ SurfaceScaleUtils.computePixelScale(hasPixelScale, hasPixelScale, reqPixelScale, nativePixelScale, DEBUG ? getClass().getSimpleName() : null);
+ if( hadPixelScaleX != hasPixelScale[0] || hadPixelScaleY != hasPixelScale[1] ) {
+ reshapeImpl(getWidth(), getHeight());
+ final Backend b = backend;
+ if ( isInitialized && null != b ) {
updateWrappedSurfaceScale(b.getDrawable());
- reshapeImpl(getWidth(), getHeight());
display();
}
}
@@ -1882,27 +1885,36 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
alignment = 4;
}
- final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount);
+ final PixelFormat awtPixelFormat = pixelBufferProvider.getAWTPixelFormat(gl.getGLProfile(), componentCount);
+ final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount, true);
if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer
- pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(pixelAttribs);
+ pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(awtPixelFormat.comp, pixelAttribs, true);
}
if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) {
pixelBuffer.dispose();
pixelBuffer = null;
alignedImage = null;
}
+ final boolean DEBUG_INIT;
if ( null == pixelBuffer ) {
if (0 >= panelWidth || 0 >= panelHeight ) {
return;
}
- pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, panelWidth, panelHeight, 1, true, 0);
+ pixelBuffer = pixelBufferProvider.allocate(gl, awtPixelFormat.comp, pixelAttribs, true, panelWidth, panelHeight, 1, 0);
if(DEBUG) {
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName());
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment);
- System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)+", isGL2ES3 "+gl.isGL2ES3());
System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" panelSize "+panelWidth+"x"+panelHeight+" @ scale "+getPixelScaleStr());
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelAttribs "+pixelAttribs);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" awtPixelFormat "+awtPixelFormat);
+ DEBUG_INIT = true;
+ } else {
+ DEBUG_INIT = false;
}
+ } else {
+ DEBUG_INIT = false;
}
if( offscreenDrawable.getSurfaceWidth() != panelWidth || offscreenDrawable.getSurfaceHeight() != panelHeight ) {
throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getSurfaceWidth()+"x"+offscreenDrawable.getSurfaceHeight()+", on thread "+getThreadName());
@@ -1937,6 +1949,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
final GL2ES3 gl2es3 = gl.getGL2ES3();
psm.setPackRowLength(gl2es3, panelWidth);
gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer());
+ if( DEBUG_INIT ) {
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: fboDrawable "+offscreenDrawable);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: isGL2ES3, readBuffer 0x"+Integer.toHexString(gl2es3.getDefaultReadBuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: def-readBuffer 0x"+Integer.toHexString(gl2es3.getDefaultReadBuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: def-readFBO 0x"+Integer.toHexString(gl2es3.getDefaultReadFramebuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.0: bound-readFBO 0x"+Integer.toHexString(gl2es3.getBoundFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER)));
+ }
}
if(null != glslTextureRaster) { // implies flippedVertical
@@ -1965,9 +1984,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing
// gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH!
glslTextureRaster.display(gl.getGL2ES2());
+ if( DEBUG_INIT ) {
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: fboDrawable "+fboDrawable);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: read from fbo-rb "+fboFlipped.getReadFramebuffer()+", fbo "+fboFlipped);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: isGL2ES3, readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: def-readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: def-readFBO 0x"+Integer.toHexString(gl.getDefaultReadFramebuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: bound-readFBO 0x"+Integer.toHexString(gl.getBoundFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER)));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.1: "+GLJPanel.this.getName()+" pixelAttribs "+pixelAttribs);
+ }
gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts);
fboFlipped.unbind(gl);
+ if( DEBUG_INIT ) {
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: fboDrawable "+fboDrawable);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: read from fbo-rb "+fboFlipped.getReadFramebuffer()+", fbo "+fboFlipped);
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: isGL2ES3, readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: def-readBuffer 0x"+Integer.toHexString(gl.getDefaultReadBuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: def-readFBO 0x"+Integer.toHexString(gl.getDefaultReadFramebuffer()));
+ System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0.2: bound-readFBO 0x"+Integer.toHexString(gl.getBoundFramebuffer(GL2ES3.GL_READ_FRAMEBUFFER)));
+ }
if( viewportChange ) {
gl.glViewport(usrViewport[0], usrViewport[1], usrViewport[2], usrViewport[3]);
}