aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java130
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java51
-rw-r--r--src/jogl/classes/javax/media/opengl/GLDrawableFactory.java37
-rw-r--r--src/jogl/classes/javax/media/opengl/GLProfile.java46
-rw-r--r--src/jogl/classes/jogamp/opengl/GLContextImpl.java55
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java42
-rw-r--r--src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java95
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java51
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java302
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java19
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java5
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java7
14 files changed, 604 insertions, 246 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
new file mode 100644
index 000000000..13c94c6f2
--- /dev/null
+++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
@@ -0,0 +1,130 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+package com.jogamp.opengl;
+
+/**
+ * GLRendererQuirks contains information of known bugs of various GL renderer.
+ * This information allows us to workaround them.
+ * <p>
+ * Using centralized quirk identifier enables us to
+ * locate code dealing w/ it and hence eases it's maintenance.
+ * </p>
+ */
+public class GLRendererQuirks {
+ /** Crashes XServer when using double buffered PBuffer with 'Mesa DRI Intel(R) Sandybridge Desktop' & 'Mesa DRI Intel(R) Ivybridge Mobile - 3.0 Mesa 8.0.4' */
+ public static final int NoDoubleBufferedPBuffer = 0;
+
+ /** On Windows no double buffered bitmaps are guaranteed to be available. */
+ public static final int NoDoubleBufferedBitmap = 1;
+
+ /** Crashes application when trying to set EGL swap interval on Android 4.0.3 / Pandaboard ES / PowerVR SGX 540 */
+ public static final int NoSetSwapInterval = 2;
+
+ /** No offscreen bitmap available, currently true for JOGL's OSX implementation. */
+ public static final int NoOffscreenBitmap = 3;
+
+ /** Number of quirks known. */
+ public static final int COUNT = 4;
+
+ private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval",
+ "NoOffscreenBitmap"
+ };
+
+ private final int _bitmask;
+
+ /**
+ * @param quirks an array of valid quirks
+ * @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 GLRendererQuirks(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);
+ }
+ for(int i=offset; i<offset+len; i++) {
+ final int quirk = quirks[i];
+ validateQuirk(quirk);
+ bitmask |= 1 << quirk;
+ }
+ _bitmask = bitmask;
+ }
+
+ /**
+ * @param quirk the quirk to be tested
+ * @return true if quirk exist, otherwise false
+ * @throws IllegalArgumentException if quirk is out of range
+ */
+ public final boolean exist(int quirk) throws IllegalArgumentException {
+ validateQuirk(quirk);
+ return 0 != ( ( 1 << quirk ) & _bitmask );
+ }
+
+ public final StringBuilder toString(StringBuilder sb) {
+ if(null == sb) {
+ sb = new StringBuilder();
+ }
+ sb.append("[");
+ boolean first=true;
+ for(int i=0; i<COUNT; i++) {
+ final int testmask = 1 << i;
+ if( 0 != ( _bitmask & testmask ) ) {
+ if(!first) { sb.append(", "); }
+ sb.append(toString(i));
+ first=false;
+ }
+ }
+ sb.append("]");
+ return sb;
+ }
+
+ public final String toString() {
+ return toString(null).toString();
+ }
+
+ /**
+ * @param quirk the quirk to be validated, i.e. whether it is out of range
+ * @throws IllegalArgumentException if quirk is out of range
+ */
+ public static void validateQuirk(int quirk) throws IllegalArgumentException {
+ if( !( 0 <= quirk && quirk < COUNT ) ) {
+ throw new IllegalArgumentException("Quirks must be in range [0.."+COUNT+"[, but quirk: "+quirk);
+ }
+ }
+
+ /**
+ * @param quirk the quirk to be converted to String
+ * @return the String equivalent of this quirk
+ * @throws IllegalArgumentException if quirk is out of range
+ */
+ public static final String toString(int quirk) throws IllegalArgumentException {
+ validateQuirk(quirk);
+ return _names[quirk];
+ }
+}
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index a5e639c74..93b9bfe82 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -55,6 +55,7 @@ import com.jogamp.common.os.Platform;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
import com.jogamp.opengl.GLExtensions;
+import com.jogamp.opengl.GLRendererQuirks;
/** Abstraction for an OpenGL rendering context. In order to perform
OpenGL rendering, a context must be "made current" on the current
@@ -159,6 +160,7 @@ public abstract class GLContext {
protected int ctxOptions;
protected String ctxVersionString;
private int currentSwapInterval;
+ protected GLRendererQuirks glRendererQuirks;
protected void resetStates() {
if (DEBUG) {
@@ -172,8 +174,31 @@ public abstract class GLContext {
attachedObjects.clear();
contextHandle=0;
currentSwapInterval = -1;
+ glRendererQuirks = null;
}
+ /**
+ * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds.
+ * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise <code>null</code>.
+ */
+ public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; }
+
+ /**
+ * Returns true if the <code>quirk</code> exist in {@link #getRendererQuirks()}, otherwise false.
+ * <p>
+ * Convenience method for:
+ * <pre>
+ * final GLRendererQuirks glrq = ctx.getRendererQuirks();
+ * boolean hasQuirk = null != glrq ? glrq.exist(quirk) : false ;
+ * </pre>
+ * </p>
+ * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
+ * @throws IllegalArgumentException if the quirk is out of range
+ */
+ public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException {
+ return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ;
+ }
+
/**
* Sets the read/write drawable for framebuffer operations.
* <p>
@@ -464,6 +489,12 @@ public abstract class GLContext {
sb.append(toHexString(contextHandle));
sb.append(", ");
sb.append(getGL());
+ sb.append(",\n\t quirks: ");
+ if(null != glRendererQuirks) {
+ glRendererQuirks.toString(sb);
+ } else {
+ sb.append("n/a");
+ }
if(getGLDrawable()!=getGLReadDrawable()) {
sb.append(",\n\tRead Drawable : ");
sb.append(getGLReadDrawable());
@@ -473,8 +504,6 @@ public abstract class GLContext {
sb.append(",\n\tDrawable: ");
sb.append(getGLDrawable());
}
- sb.append(", lock ");
- sb.append(lock.toString());
return sb;
}
@@ -666,13 +695,15 @@ public abstract class GLContext {
if( hasFullFBOSupport() ) {
final GL gl = getGL();
final int[] val = new int[] { 0 } ;
- gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0);
- final int glerr = gl.glGetError();
- if(GL.GL_NO_ERROR == glerr) {
- return val[0];
- } else if(DEBUG) {
- System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr));
- }
+ try {
+ gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0);
+ final int glerr = gl.glGetError();
+ if(GL.GL_NO_ERROR == glerr) {
+ return val[0];
+ } else if(DEBUG) {
+ System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr));
+ }
+ } catch (GLException gle) { gle.printStackTrace(); }
}
return 0;
}
@@ -1369,6 +1400,6 @@ public abstract class GLContext {
protected static String getThreadName() {
return Thread.currentThread().getName();
}
-
+
}
diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
index b6e7b0576..ae49eeeff 100644
--- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
+++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java
@@ -49,6 +49,7 @@ import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.opengl.GLAutoDrawableDelegate;
+import com.jogamp.opengl.GLRendererQuirks;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
@@ -308,6 +309,42 @@ public abstract class GLDrawableFactory {
protected abstract boolean createSharedResource(AbstractGraphicsDevice device);
/**
+ * Returns true if the <code>quirk</code> exist in the shared resource's context {@link GLRendererQuirks}.
+ * <p>
+ * Convenience method for:
+ * <pre>
+ final GLRendererQuirks glrq = factory.getRendererQuirks(device);
+ return null != glrq ? glrq.exist(quirk) : false;
+ * </pre>
+ * </p>
+ *
+ * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+ * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}.
+ * @throws IllegalArgumentException if the quirk is out of range
+ * @see #getRendererQuirks()
+ * @see GLRendererQuirks
+ */
+ public final boolean hasRendererQuirk(AbstractGraphicsDevice device, int quirk) {
+ final GLRendererQuirks glrq = getRendererQuirks(device);
+ return null != glrq ? glrq.exist(quirk) : false;
+ }
+
+ /**
+ * Returns the shared resource's context {@link GLRendererQuirks}.
+ * <p>
+ * Implementation calls {@link GLContext#getRendererQuirks()} on the shared resource context.
+ * </p>
+ * <p>
+ * In case no shared device exist yet or the implementation doesn't support tracking quirks,
+ * the result is always <code>null</code>.
+ * </p>
+ * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be <code>null</code> for the platform's default device.
+ * @see GLContext#getRendererQuirks()
+ * @see GLRendererQuirks
+ */
+ public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device);
+
+ /**
* Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null
*/
public static GLDrawableFactory getDesktopFactory() {
diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java
index 23d789afd..aabda465e 100644
--- a/src/jogl/classes/javax/media/opengl/GLProfile.java
+++ b/src/jogl/classes/javax/media/opengl/GLProfile.java
@@ -1445,10 +1445,6 @@ public class GLProfile {
}
} else {
defaultDesktopDevice = desktopFactory.getDefaultDevice();
- defaultDevice = defaultDesktopDevice;
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice);
- }
}
if ( !disableOpenGLES && ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) {
@@ -1490,7 +1486,7 @@ public class GLProfile {
}
}
- final AbstractGraphicsDevice defaultEGLDevice;
+ final AbstractGraphicsDevice defaultEGLDevice;
if(null == eglFactory) {
hasGLES2Impl = false;
hasGLES1Impl = false;
@@ -1499,25 +1495,33 @@ public class GLProfile {
System.err.println("Info: GLProfile.init - EGL GLDrawable factory not available");
}
} else {
- defaultEGLDevice = eglFactory.getDefaultDevice();
- if(null == defaultDevice) {
- defaultDevice = defaultEGLDevice;
- if(DEBUG) {
- System.err.println("Info: GLProfile.init - Default device is EGL derived: "+defaultDevice);
- }
- }
+ defaultEGLDevice = eglFactory.getDefaultDevice();
}
- /** Should not be required .. but keep it here if simple probe on defaultDevice ain't enough.
- final boolean addedDesktopProfile = initProfilesForDevice(defaultDesktopDevice);
- final boolean addedEGLProfile = initProfilesForDevice(defaultEGLDevice);
- final boolean addedAnyProfile = addedDesktopProfile || addedEGLProfile ;
- */
- final boolean addedAnyProfile = initProfilesForDevice(defaultDevice);
-
+ if( null != defaultDesktopDevice ) {
+ defaultDevice = defaultDesktopDevice;
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice);
+ }
+ } else if ( null != defaultEGLDevice ) {
+ defaultDevice = defaultEGLDevice;
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - Default device is EGL derived: "+defaultDevice);
+ }
+ } else {
+ if(DEBUG) {
+ System.err.println("Info: GLProfile.init - Default device not available");
+ }
+ defaultDevice = null;
+ }
+
+ // we require to initialize the EGL device 1st, if available
+ final boolean addedEGLProfile = null != defaultEGLDevice ? initProfilesForDevice(defaultEGLDevice) : false;
+ final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false;
+ final boolean addedAnyProfile = addedEGLProfile || addedDesktopProfile ;
+
if(DEBUG) {
- // System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")");
- System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile);
+ System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")");
System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable);
System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory);
System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl);
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
index 050c619fd..e164dfe44 100644
--- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java
@@ -46,6 +46,7 @@ import java.util.HashMap;
import java.util.Map;
import com.jogamp.common.os.DynamicLookupHelper;
+import com.jogamp.common.os.Platform;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.gluegen.runtime.FunctionAddressResolver;
@@ -53,6 +54,7 @@ import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLNameResolver;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
import com.jogamp.opengl.GLExtensions;
+import com.jogamp.opengl.GLRendererQuirks;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -162,7 +164,7 @@ public abstract class GLContextImpl extends GLContext {
additionalCtxCreationFlags = 0;
glRenderer = "";
- glRendererLowerCase = glRenderer;
+ glRendererLowerCase = glRenderer;
if (boundFBOTarget != null) { // <init>
boundFBOTarget[0] = 0; // draw
@@ -1116,13 +1118,6 @@ public abstract class GLContextImpl extends GLContext {
}
}
- protected final String getGLVersionString() {
- return glVersion;
- }
- protected final String getGLRendererString(boolean lowerCase) {
- return lowerCase ? glRendererLowerCase : glRenderer;
- }
-
/**
* Sets the OpenGL implementation class and
* the cache of which GL functions are available for calling through this
@@ -1264,6 +1259,8 @@ public abstract class GLContextImpl extends GLContext {
// Set GL Version (complete w/ version string)
//
setContextVersion(major, minor, ctxProfileBits, true);
+
+ setRendererQuirks();
setDefaultSwapInterval();
@@ -1272,7 +1269,45 @@ public abstract class GLContextImpl extends GLContext {
}
}
- protected static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) {
+ private final void setRendererQuirks() {
+ int[] quirks = new int[GLRendererQuirks.COUNT];
+ int i = 0;
+
+ // OS related quirks
+ if( Platform.getOSType() == Platform.OSType.MACOS ) {
+ final int quirk = GLRendererQuirks.NoOffscreenBitmap;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType());
+ }
+ quirks[i++] = quirk;
+ } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) {
+ final int quirk = GLRendererQuirks.NoDoubleBufferedBitmap;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType());
+ }
+ quirks[i++] = quirk;
+ }
+
+ // Renderer related quirks, may also involve OS
+ if( Platform.OSType.ANDROID == Platform.getOSType() && glRendererLowerCase.contains("powervr") ) {
+ final int quirk = GLRendererQuirks.NoSetSwapInterval;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer);
+ }
+ quirks[i++] = quirk;
+ }
+ if( glRendererLowerCase.contains("intel(r)") && glRendererLowerCase.contains("mesa") ) {
+ final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer;
+ if(DEBUG) {
+ System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer);
+ }
+ quirks[i++] = quirk;
+ }
+ glRendererQuirks = new GLRendererQuirks(quirks, 0, i);
+ }
+
+
+ private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) {
return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) || // ES >= 2.0
major >= 3 || // any >= 3.0 GL ctx
@@ -1288,7 +1323,7 @@ public abstract class GLContextImpl extends GLContext {
extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded
}
- protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) {
+ private final void removeCachedVersion(int major, int minor, int ctxProfileBits) {
if(!isCurrentContextHardwareRasterizer()) {
ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT;
}
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index 4f965f620..bd2db1b81 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -63,6 +63,7 @@ import javax.media.opengl.GLProfile;
import com.jogamp.nativewindow.MutableGraphicsConfiguration;
import com.jogamp.nativewindow.DelegatedUpstreamSurfaceHookWithSurfaceSize;
import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize;
+import com.jogamp.opengl.GLRendererQuirks;
/** Extends GLDrawableFactory with a few methods for handling
@@ -78,6 +79,15 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
super();
}
+ @Override
+ public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) {
+ final GLContext ctx = getOrCreateSharedContextImpl(device);
+ if(null != ctx) {
+ return ctx.getRendererQuirks();
+ }
+ return null;
+ }
+
/**
* Returns the shared context mapped to the <code>device</code> {@link AbstractGraphicsDevice#getConnection()},
* either a pre-existing or newly created, or <code>null</code> if creation failed or not supported.<br>
@@ -102,24 +112,15 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
* @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be <code>null</code> for the platform's default device.
*/
protected final AbstractGraphicsDevice getOrCreateSharedDevice(AbstractGraphicsDevice device) {
- if(null==device) {
- device = getDefaultDevice();
- if(null==device) {
- throw new InternalError("no default device");
- }
- if (GLProfile.DEBUG) {
- System.err.println("Info: GLDrawableFactoryImpl.getOrCreateSharedContext: using default device : "+device);
- }
- } else if( !getIsDeviceCompatible(device) ) {
- if (GLProfile.DEBUG) {
- System.err.println("Info: GLDrawableFactoryImpl.getOrCreateSharedContext: device not compatible : "+device);
- }
- return null;
+ device = validateDevice(device);
+ if( null != device) {
+ return getOrCreateSharedDeviceImpl(device);
}
- return getOrCreateSharedDeviceImpl(device);
+ return null;
}
protected abstract AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device);
+
/**
* Returns the GLDynamicLookupHelper
* @param profile if EGL/ES, profile <code>1</code> refers to ES1 and <code>2</code> to ES2,
@@ -144,12 +145,11 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
try {
final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true);
if(null != ols) {
+ final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, this, adevice);
// layered surface -> Offscreen/[FBO|PBuffer]
- final boolean isPbufferAvailable = canCreateGLPbuffer(adevice) ;
- if(!isPbufferAvailable && !isFBOAvailable) {
- throw new GLException("Neither FBO nor Pbuffer is available for "+target);
+ if( !chosenCapsMod.isFBO() && !chosenCapsMod.isPBuffer() ) {
+ throw new GLException("Neither FBO nor Pbuffer is available for "+chosenCapsMod+", "+target);
}
- final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, isFBOAvailable, isPbufferAvailable);
config.setChosenCapabilities(chosenCapsMod);
ols.setChosenCapabilities(chosenCapsMod);
if(DEBUG) {
@@ -163,7 +163,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
if( ! ( target instanceof MutableSurface ) ) {
throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target);
}
- if( chosenCapsMod.isFBO() && isFBOAvailable ) {
+ if( chosenCapsMod.isFBO() ) {
// target surface is already a native one
result = createFBODrawableImpl(target, chosenCapsMod, 0);
} else {
@@ -294,9 +294,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory {
throw new GLException("No shared device for requested: "+deviceReq);
}
- final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested,
- GLContext.isFBOAvailable(device, capsRequested.getGLProfile()),
- canCreateGLPbuffer(device));
+ final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, this, device);
if( capsChosen.isFBO() ) {
device.lock();
diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
index 13c95b0dd..31e52b86c 100644
--- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
+++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java
@@ -32,8 +32,9 @@ import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
-import com.jogamp.common.os.Platform;
+import com.jogamp.opengl.GLRendererQuirks;
public class GLGraphicsConfigurationUtil {
public static final String NV_coverage_sample = "NV_coverage_sample";
@@ -138,16 +139,25 @@ public class GLGraphicsConfigurationUtil {
return caps;
}
- public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable)
- {
+ /**
+ * Fixes the requested {@link GLCapabilitiesImmutable} according to on- and offscreen usage.
+ * <p>
+ * No modification will be made for onscreen usage, for offscreen usage see
+ * {@link #fixOffscreenGLCapabilities(GLCapabilitiesImmutable, GLDrawableFactory, AbstractGraphicsDevice)}.
+ * </p>
+ * @param capsRequested the requested {@link GLCapabilitiesImmutable}
+ * @param factory the {@link GLDrawableFactory} used to validate the requested capabilities and later used to create the drawable.
+ * @param device the device on which the drawable will be created, maybe null for the {@link GLDrawableFactory#getDefaultDevice() default device}.
+ * @return either the given requested {@link GLCapabilitiesImmutable} instance if no modifications were required, or a modified {@link GLCapabilitiesImmutable} instance.
+ */
+ public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested,
+ GLDrawableFactory factory, AbstractGraphicsDevice device) {
if( !capsRequested.isOnscreen() ) {
- return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable);
- } /* we maintain the offscreen mode flags in onscreen mode - else {
- return fixOnscreenGLCapabilities(capsRequested);
- } */
+ return fixOffscreenGLCapabilities(capsRequested, factory, device);
+ }
return capsRequested;
}
-
+
public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested)
{
if( !capsRequested.isOnscreen() || capsRequested.isFBO() || capsRequested.isPBuffer() || capsRequested.isBitmap() ) {
@@ -162,25 +172,68 @@ public class GLGraphicsConfigurationUtil {
return capsRequested;
}
- public static boolean isGLCapabilitiesOffscreenAutoSelection(GLCapabilitiesImmutable capsRequested) {
- return !capsRequested.isOnscreen() &&
- !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ;
+ public static GLCapabilitiesImmutable fixOffscreenBitOnly(GLCapabilitiesImmutable capsRequested)
+ {
+ if( capsRequested.isOnscreen() ) {
+ // fix caps ..
+ final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
+ caps2.setOnscreen(false);
+ return caps2;
+ }
+ return capsRequested;
}
-
- public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) {
- final boolean auto = !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ;
-
- final boolean requestedPBuffer = capsRequested.isPBuffer() || Platform.getOSType() == Platform.OSType.MACOS ; // no native bitmap for OSX
+
+ /**
+ * Fixes the requested {@link GLCapabilitiesImmutable} according to:
+ * <ul>
+ * <li>offscreen usage</li>
+ * <li>availability of FBO, PBuffer, Bitmap</li>
+ * <li>{@link GLRendererQuirks}</li>
+ * </ul>
+ * @param capsRequested the requested {@link GLCapabilitiesImmutable}
+ * @param factory the {@link GLDrawableFactory} used to validate the requested capabilities and later used to create the drawable.
+ * @param device the device on which the drawable will be created, maybe null for the {@link GLDrawableFactory#getDefaultDevice() default device}.
+ * @return either the given requested {@link GLCapabilitiesImmutable} instance if no modifications were required, or a modified {@link GLCapabilitiesImmutable} instance.
+ */
+ public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested,
+ GLDrawableFactory factory, AbstractGraphicsDevice device) {
+ if(null == device) {
+ device = factory.getDefaultDevice();
+ }
+ final boolean fboAvailable = GLContext.isFBOAvailable(device, capsRequested.getGLProfile());
+ final boolean pbufferAvailable = factory.canCreateGLPbuffer(device);
+
+ final GLRendererQuirks glrq = factory.getRendererQuirks(device);
+ final boolean bitmapAvailable;
+ final boolean doubleBufferAvailable;
+
+ if(null != glrq) {
+ bitmapAvailable = !glrq.exist(GLRendererQuirks.NoOffscreenBitmap);
+ if( capsRequested.getDoubleBuffered() &&
+ ( capsRequested.isPBuffer() && glrq.exist(GLRendererQuirks.NoDoubleBufferedPBuffer) ) ||
+ ( capsRequested.isBitmap() && glrq.exist(GLRendererQuirks.NoDoubleBufferedBitmap) ) ) {
+ doubleBufferAvailable = false;
+ } else {
+ doubleBufferAvailable = true;
+ }
+ } else {
+ bitmapAvailable = true;
+ doubleBufferAvailable = true;
+ }
- final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ;
- final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || requestedPBuffer ) ;
- final boolean useBitmap = !useFBO && !usePbuffer && ( auto || capsRequested.isBitmap() ) ;
+ final boolean auto = !( fboAvailable && capsRequested.isFBO() ) &&
+ !( pbufferAvailable && capsRequested.isPBuffer() ) &&
+ !( bitmapAvailable && capsRequested.isBitmap() ) ;
+
+ final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ;
+ final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || capsRequested.isPBuffer() ) ;
+ final boolean useBitmap = !useFBO && !usePbuffer && bitmapAvailable && ( auto || capsRequested.isBitmap() ) ;
if( capsRequested.isOnscreen() ||
useFBO != capsRequested.isFBO() ||
usePbuffer != capsRequested.isPBuffer() ||
useBitmap != capsRequested.isBitmap() ||
- useBitmap && capsRequested.getDoubleBuffered() )
+ !doubleBufferAvailable && capsRequested.getDoubleBuffered() )
{
// fix caps ..
final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable();
@@ -188,7 +241,7 @@ public class GLGraphicsConfigurationUtil {
caps2.setFBO( useFBO );
caps2.setPBuffer( usePbuffer );
caps2.setBitmap( useBitmap );
- if( useBitmap ) {
+ if( !doubleBufferAvailable ) {
caps2.setDoubleBuffered(false);
}
return caps2;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 06953a8e1..84aeaa94a 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -51,9 +51,10 @@ import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableImpl;
import com.jogamp.common.nio.Buffers;
-import com.jogamp.common.os.Platform;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
+import com.jogamp.opengl.GLRendererQuirks;
public abstract class EGLContext extends GLContextImpl {
private boolean eglQueryStringInitialized;
@@ -269,14 +270,7 @@ public abstract class EGLContext extends GLContextImpl {
@Override
protected boolean setSwapIntervalImpl(int interval) {
- // FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- // eglSwapInterval(..) issued:
- // Android 4.0.3 / Pandaboard ES / PowerVR SGX 540: crashes
- // FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- if( Platform.OSType.ANDROID == Platform.getOSType() && getGLRendererString(true).contains("powervr") ) {
- if(DEBUG) {
- System.err.println("Ignored: eglSwapInterval("+interval+") - cause: OS "+Platform.getOSType() + " / Renderer " + getGLRendererString(false));
- }
+ if( hasRendererQuirk(GLRendererQuirks.NoSetSwapInterval) ) {
return false;
}
return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval);
@@ -286,20 +280,11 @@ public abstract class EGLContext extends GLContextImpl {
// Accessible ..
//
- /**
- * If context is an ES profile, map it to the given device
- * via {@link GLContext#mapAvailableGLVersion(AbstractGraphicsDevice, int, int, int, int, int)}.
- * <p>
- * We intentionally override a non native EGL device ES profile mapping,
- * i.e. this will override/modify an already 'set' X11/WGL/.. mapping.
- * </p>
- *
- * @param device
- */
- protected void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) {
- mapCurrentAvailableGLVersionImpl(device, ctxMajorVersion, ctxMinorVersion, ctxOptions);
- }
- protected static void mapStaticGLESVersion(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps) {
+ /* pp */ void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) {
+ mapStaticGLVersion(device, ctxMajorVersion, ctxMinorVersion, ctxOptions);
+ }
+ /* pp */ int getContextOptions() { return ctxOptions; }
+ /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps) {
final GLProfile glp = caps.getGLProfile();
final int[] reqMajorCTP = new int[2];
GLContext.getRequestMajorAndCompat(glp, reqMajorCTP);
@@ -309,21 +294,27 @@ public abstract class EGLContext extends GLContextImpl {
if(!caps.getHardwareAccelerated()) {
reqMajorCTP[1] |= GLContext.CTX_IMPL_ACCEL_SOFT;
}
- mapCurrentAvailableGLVersionImpl(device, reqMajorCTP[0], 0, reqMajorCTP[1]);
- }
- protected static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) {
+ mapStaticGLVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]);
+ }
+ /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) {
int ctp = ( 2 == major ) ? ( GLContext.CTX_PROFILE_ES | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) : ( GLContext.CTX_PROFILE_ES );
- mapCurrentAvailableGLVersionImpl(device, major, 0, ctp);
+ mapStaticGLVersion(device, major, 0, ctp);
}
- private static void mapCurrentAvailableGLVersionImpl(AbstractGraphicsDevice device, int major, int minor, int ctp) {
+ /* pp */ static void mapStaticGLVersion(AbstractGraphicsDevice device, int major, int minor, int ctp) {
if( 0 != ( ctp & GLContext.CTX_PROFILE_ES) ) {
// ES1 or ES2
final int reqMajor = major;
final int reqProfile = GLContext.CTX_PROFILE_ES;
- GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile,
- major, minor, ctp);
+ GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp);
+ if(! ( device instanceof EGLGraphicsDevice ) ) {
+ final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(device.getHandle(), EGL.EGL_NO_DISPLAY, device.getConnection(), device.getUnitID(), null);
+ GLContext.mapAvailableGLVersion(eglDevice, reqMajor, reqProfile, major, minor, ctp);
+ }
}
}
+ protected static String getGLVersion(int major, int minor, int ctp, String gl_version) {
+ return GLContext.getGLVersion(major, minor, ctp, gl_version);
+ }
protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) {
return GLContext.getAvailableGLVersionsSet(device);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index e98d69140..a907c4aff 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -43,6 +43,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -77,11 +78,11 @@ import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
+import com.jogamp.opengl.GLRendererQuirks;
public class EGLDrawableFactory extends GLDrawableFactoryImpl {
protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG;
- /* package */ static final boolean QUERY_EGL_ES = !Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.DontQuery", true);
/* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true);
private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null;
@@ -113,36 +114,11 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
} catch (JogampRuntimeException jre) { /* n/a .. */ }
}
- defaultDevice = new EGLGraphicsDevice();
-
// FIXME: Probably need to move EGL from a static model
// to a dynamic one, where there can be 2 instances
// for each ES profile with their own ProcAddressTable.
synchronized(EGLDrawableFactory.class) {
- /**
- * Currently AMD's EGL impl. crashes at eglGetDisplay(EGL_DEFAULT_DISPLAY)
- *
- // Check Desktop ES2 Availability first (AMD, ..)
- if(null==eglES2DynamicLookupHelper) {
- GLDynamicLookupHelper tmp=null;
- try {
- tmp = new GLDynamicLookupHelper(new DesktopES2DynamicLibraryBundleInfo());
- } catch (GLException gle) {
- if(DEBUG) {
- gle.printStackTrace();
- }
- }
- if(null!=tmp && tmp.isLibComplete()) {
- eglES2DynamicLookupHelper = tmp;
- EGL.resetProcAddressTable(eglES2DynamicLookupHelper);
- if (GLProfile.DEBUG) {
- System.err.println("Info: EGLDrawableFactory: Desktop ES2 - OK");
- }
- } else if (GLProfile.DEBUG) {
- System.err.println("Info: EGLDrawableFactory: Desktop ES2 - NOPE");
- }
- } */
final boolean hasDesktopES2 = null != eglES2DynamicLookupHelper;
if(!hasDesktopES2 && null==eglES1DynamicLookupHelper) {
@@ -188,8 +164,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
if(null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper) {
- sharedMap = new HashMap<String /*connection*/, SharedResource>();
+ sharedMap = new HashMap<String /*uniqueKey*/, SharedResource>();
sharedMapCreateAttempt = new HashSet<String>();
+ defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
}
}
}
@@ -203,6 +180,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
@Override
protected final void destroy() {
if(null != sharedMap) {
+ if(DEBUG) {
+ System.err.println("EGLDrawableFactory.destroy() .. ");
+ dumpMap();
+ }
Collection<SharedResource> srl = sharedMap.values();
for(Iterator<SharedResource> sri = srl.iterator(); sri.hasNext(); ) {
SharedResource sr = sri.next();
@@ -216,7 +197,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
sharedMap = null;
sharedMapCreateAttempt = null;
}
- defaultDevice = null;
+ if(null != defaultSharedResource) {
+ defaultSharedResource = null;
+ }
+ if(null != defaultDevice) {
+ defaultDevice.close();
+ defaultDevice = null;
+ }
/**
* Pulling away the native library may cause havoc ..
*/
@@ -231,39 +218,63 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
EGLGraphicsConfigurationFactory.unregisterFactory();
EGLDisplayUtil.shutdown(DEBUG);
}
+
+ private void dumpMap() {
+ synchronized(sharedMap) {
+ System.err.println("EGLDrawableFactory.map "+sharedMap.size());
+ int i=0;
+ Set<String> keys = sharedMap.keySet();
+ for(Iterator<String> keyI = keys.iterator(); keyI.hasNext(); i++) {
+ String key = keyI.next();
+ SharedResource sr = sharedMap.get(key);
+ System.err.println("EGLDrawableFactory.map["+i+"] "+key+" -> "+sr.getDevice()+", "+
+ "es1 [avail "+sr.wasES1ContextAvailable()+", pbuffer "+sr.hasES1PBuffer()+", quirks "+sr.getGLRendererQuirksES1()+", ctp "+EGLContext.getGLVersion(1, 0, sr.getCtpES1(), null)+"], "+
+ "es2 [avail "+sr.wasES2ContextAvailable()+", pbuffer "+sr.hasES2PBuffer()+", quirks "+sr.getGLRendererQuirksES1()+", ctp "+EGLContext.getGLVersion(2, 0, sr.getCtpES2(), null)+"]");
+ }
+ ;
+ }
+ }
- private HashMap<String /*connection*/, SharedResource> sharedMap = null;
+ private HashMap<String /*uniqueKey*/, SharedResource> sharedMap = null;
private HashSet<String> sharedMapCreateAttempt = null;
-
- private EGLGraphicsDevice defaultDevice;
+ private EGLGraphicsDevice defaultDevice = null;
+ private SharedResource defaultSharedResource = null;
static class SharedResource {
private final EGLGraphicsDevice device;
- // private final EGLDrawable drawable;
// private final EGLContext contextES1;
// private final EGLContext contextES2;
+ private final GLRendererQuirks rendererQuirksES1;
+ private final GLRendererQuirks rendererQuirksES2;
+ private final int ctpES1;
+ private final int ctpES2;
private final boolean wasES1ContextCreated;
private final boolean wasES2ContextCreated;
private final boolean hasPBufferES1;
private final boolean hasPBufferES2;
SharedResource(EGLGraphicsDevice dev,
- boolean wasContextES1Created, boolean hasPBufferES1,
- boolean wasContextES2Created, boolean hasPBufferES2
- /*EGLDrawable draw, EGLContext ctxES1, EGLContext ctxES2 */) {
+ boolean wasContextES1Created, boolean hasPBufferES1, GLRendererQuirks rendererQuirksES1, int ctpES1,
+ boolean wasContextES2Created, boolean hasPBufferES2, GLRendererQuirks rendererQuirksES2, int ctpES2) {
this.device = dev;
- // this.drawable = draw;
// this.contextES1 = ctxES1;
// this.contextES2 = ctxES2;
+ this.rendererQuirksES1 = rendererQuirksES1;
+ this.rendererQuirksES2 = rendererQuirksES2;
+ this.ctpES1 = ctpES1;
+ this.ctpES2 = ctpES2;
this.wasES1ContextCreated = wasContextES1Created;
this.wasES2ContextCreated = wasContextES2Created;
this.hasPBufferES1= hasPBufferES1;
this.hasPBufferES2= hasPBufferES2;
}
final EGLGraphicsDevice getDevice() { return device; }
- // final EGLDrawable getDrawable() { return drawable; }
// final EGLContext getContextES1() { return contextES1; }
// final EGLContext getContextES2() { return contextES2; }
+ final GLRendererQuirks getGLRendererQuirksES1() { return rendererQuirksES1; }
+ final GLRendererQuirks getGLRendererQuirksES2() { return rendererQuirksES2; }
+ final int getCtpES1() { return ctpES1; }
+ final int getCtpES2() { return ctpES2; }
final boolean wasES1ContextAvailable() { return wasES1ContextCreated; }
final boolean wasES2ContextAvailable() { return wasES2ContextCreated; }
final boolean hasES1PBuffer() { return hasPBufferES1; }
@@ -297,12 +308,23 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return new ArrayList<GLCapabilitiesImmutable>(0);
}
- private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, EGLGraphicsDevice sharedEGLDevice, String profileString, boolean[] hasPBuffer) {
- if( !GLProfile.isAvailable(adevice, profileString) ) {
+ private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int esProfile,
+ boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) {
+ final String profileString;
+ switch( esProfile ) {
+ case 1:
+ profileString = GLProfile.GLES1; break;
+ case 2:
+ default:
+ profileString = GLProfile.GLES2; break;
+ }
+ if ( !GLProfile.isAvailable(adevice, profileString) ) {
return false;
}
final GLProfile glp = GLProfile.get(adevice, profileString) ;
final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory();
+ final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || null == desktopFactory || adevice instanceof EGLGraphicsDevice ;
+
EGLGraphicsDevice eglDevice = null;
NativeSurface surface = null;
ProxySurface upstreamSurface = null; // X11, GLX, ..
@@ -312,27 +334,49 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
final GLCapabilities reqCapsAny = new GLCapabilities(glp);
reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0);
reqCapsAny.setDoubleBuffered(false);
- final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny);
- final List<GLCapabilitiesImmutable> availablePBufferCapsL = getAvailableEGLConfigs(sharedEGLDevice, reqCapsPBuffer);
- hasPBuffer[0] = availablePBufferCapsL.size() > 0;
- if(adevice instanceof EGLGraphicsDevice || null == desktopFactory || !QUERY_EGL_ES_NATIVE_TK) {
- eglDevice = sharedEGLDevice; // reuse
+ if( mapsADeviceToDefaultDevice ) {
+ // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior).
+ // Only one default shared resource instance is ever be created.
+ final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny);
+ final List<GLCapabilitiesImmutable> availablePBufferCapsL = getAvailableEGLConfigs(defaultDevice, reqCapsPBuffer);
+ hasPBuffer[0] = availablePBufferCapsL.size() > 0;
+
+ // 1st case: adevice is not the EGL default device, map default shared resources
+ if( adevice != defaultDevice ) {
+ if(null == defaultSharedResource) {
+ return false;
+ }
+ switch(esProfile) {
+ case 1:
+ rendererQuirks[0] = defaultSharedResource.rendererQuirksES1;
+ ctp[0] = defaultSharedResource.ctpES1;
+ break;
+ case 2:
+ rendererQuirks[0] = defaultSharedResource.rendererQuirksES2;
+ ctp[0] = defaultSharedResource.ctpES2;
+ break;
+ }
+ EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]);
+ return true;
+ }
+
+ // attempt to created the default shared resources ..
+
+ eglDevice = defaultDevice; // reuse
+
if( hasPBuffer[0] ) {
+ // 2nd case create defaultDevice shared resource using pbuffer surface
surface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen
upstreamSurface = (ProxySurface)surface;
upstreamSurface.createNotify();
deviceFromUpstreamSurface = false;
} else {
+ // 3rd case fake creation of defaultDevice shared resource, no pbuffer available
final List<GLCapabilitiesImmutable> capsAnyL = getAvailableEGLConfigs(eglDevice, reqCapsAny);
if(capsAnyL.size() > 0) {
final GLCapabilitiesImmutable chosenCaps = capsAnyL.get(0);
EGLContext.mapStaticGLESVersion(eglDevice, chosenCaps);
- if(eglDevice != adevice) {
- EGLContext.mapStaticGLESVersion(adevice, chosenCaps);
- }
- final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null);
- EGLContext.mapStaticGLESVersion(adeviceEGLDevice, chosenCaps);
success = true;
}
if(DEBUG) {
@@ -341,6 +385,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
}
} else {
+ // 4th case always creates a true mapping of given device to EGL
surface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window
upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ;
if(null != upstreamSurface) {
@@ -365,8 +410,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
if(eglDevice != adevice) {
context.mapCurrentAvailableGLVersion(adevice);
}
- final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null);
- context.mapCurrentAvailableGLVersion(adeviceEGLDevice);
+ rendererQuirks[0] = context.getRendererQuirks();
+ ctp[0] = context.getContextOptions();
success = true;
} else {
// Oops .. something is wrong
@@ -393,7 +438,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
}
success = false;
} finally {
- if(eglDevice == sharedEGLDevice) {
+ if(eglDevice == defaultDevice) {
if(null != upstreamSurface) {
upstreamSurface.destroyNotify();
}
@@ -416,67 +461,101 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
return success;
}
- /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) {
- if(null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper
- return null;
- }
- final String connection = adevice.getConnection();
- SharedResource sr;
- boolean createAttempted;
+ private final boolean needsToCreateSharedResource(String key, SharedResource[] existing) {
synchronized(sharedMap) {
- sr = sharedMap.get(connection);
+ final SharedResource sr = sharedMap.get(key);
if( null == sr ) {
- createAttempted = sharedMapCreateAttempt.contains(connection);
+ final boolean createAttempted = sharedMapCreateAttempt.contains(key);
if(!createAttempted) {
- sharedMapCreateAttempt.add(connection);
+ sharedMapCreateAttempt.add(key);
}
+ return !createAttempted;
} else {
- createAttempted = true;
- }
- }
- if(null==sr && !createAttempted) {
- final boolean madeCurrentES1;
- final boolean madeCurrentES2;
- final EGLGraphicsDevice sharedDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- boolean[] hasPBufferES1 = new boolean[1];
- boolean[] hasPBufferES2 = new boolean[1];
-
- if(QUERY_EGL_ES) {
- madeCurrentES1 = mapAvailableEGLESConfig(adevice, sharedDevice, GLProfile.GLES1, hasPBufferES1);
- madeCurrentES2 = mapAvailableEGLESConfig(adevice, sharedDevice, GLProfile.GLES2, hasPBufferES2);
- } else {
- madeCurrentES1 = true;
- madeCurrentES2 = true;
- hasPBufferES1[0] = true;
- hasPBufferES2[0] = true;
- EGLContext.mapStaticGLESVersion(sharedDevice, 1);
- if(sharedDevice != adevice) {
- EGLContext.mapStaticGLESVersion(adevice, 1);
- }
- EGLContext.mapStaticGLESVersion(sharedDevice, 2);
- if(sharedDevice != adevice) {
- EGLContext.mapStaticGLESVersion(adevice, 2);
+ if(null != existing) {
+ existing[0] = sr;
}
+ return false;
}
-
- if( !EGLContext.getAvailableGLVersionsSet(adevice) ) {
- // Even though we override the non EGL native mapping intentionally,
- // avoid exception due to double 'set' - carefull exception of the rule.
- EGLContext.setAvailableGLVersionsSet(adevice);
+ }
+ }
+
+ /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) {
+ if(null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper
+ return null;
+ }
+
+ if( needsToCreateSharedResource(defaultDevice.getUniqueID(), null) ) {
+ if (DEBUG) {
+ System.err.println("EGLDrawableFactory.createShared: (defaultDevice): req. device: "+adevice+", defaultDevice "+defaultDevice);
+ Thread.dumpStack();
}
- sr = new SharedResource(sharedDevice, madeCurrentES1, hasPBufferES1[0], madeCurrentES2, hasPBufferES2[0]);
-
- synchronized(sharedMap) {
- sharedMap.put(connection, sr);
- if(adevice != sharedDevice) {
- sharedMap.put(sharedDevice.getConnection(), sr);
- }
+ if(null != defaultSharedResource) {
+ dumpMap();
+ throw new InternalError("defaultSharedResource already exist: "+defaultSharedResource);
}
- if (DEBUG) {
- System.err.println("EGLDrawableFactory.createShared: devices: queried " + QUERY_EGL_ES + "[nativeTK "+QUERY_EGL_ES_NATIVE_TK+"], " + adevice + ", " + sharedDevice);
- System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]);
- System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES2[0]);
+ defaultSharedResource = createEGLSharedResourceImpl(defaultDevice);
+ }
+
+ final String key = adevice.getUniqueID();
+ if( defaultDevice.getUniqueID().equals(key) ) {
+ return defaultSharedResource;
+ } else {
+ if( null == defaultSharedResource) { // defaultDevice must be initialized before host-device
+ dumpMap();
+ throw new InternalError("defaultSharedResource does not exist");
}
+ final SharedResource[] existing = new SharedResource[] { null };
+ if ( !needsToCreateSharedResource(key, existing) ) {
+ return existing[0];
+ }
+ return createEGLSharedResourceImpl(adevice);
+ }
+ }
+
+ private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) {
+ final boolean madeCurrentES1;
+ final boolean madeCurrentES2;
+ boolean[] hasPBufferES1 = new boolean[] { false };
+ boolean[] hasPBufferES2 = new boolean[] { false };
+ // EGLContext[] eglCtxES1 = new EGLContext[] { null };
+ // EGLContext[] eglCtxES2 = new EGLContext[] { null };
+ GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] { null };
+ GLRendererQuirks[] rendererQuirksES2 = new GLRendererQuirks[] { null };
+ int[] ctpES1 = new int[] { -1 };
+ int[] ctpES2 = new int[] { -1 };
+
+
+ if (DEBUG) {
+ System.err.println("EGLDrawableFactory.createShared(): device "+adevice);
+ }
+
+ if( null != eglES1DynamicLookupHelper ) {
+ madeCurrentES1 = mapAvailableEGLESConfig(adevice, 1, hasPBufferES1, rendererQuirksES1, ctpES1);
+ } else {
+ madeCurrentES1 = false;
+ }
+ if( null != eglES2DynamicLookupHelper ) {
+ madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES2, rendererQuirksES2, ctpES2);
+ } else {
+ madeCurrentES2 = false;
+ }
+
+ if( !EGLContext.getAvailableGLVersionsSet(adevice) ) {
+ // Even though we override the non EGL native mapping intentionally,
+ // avoid exception due to double 'set' - carefull exception of the rule.
+ EGLContext.setAvailableGLVersionsSet(adevice);
+ }
+ final SharedResource sr = new SharedResource(defaultDevice, madeCurrentES1, hasPBufferES1[0], rendererQuirksES1[0], ctpES1[0],
+ madeCurrentES2, hasPBufferES2[0], rendererQuirksES2[0], ctpES2[0]);
+
+ synchronized(sharedMap) {
+ sharedMap.put(adevice.getUniqueID(), sr);
+ }
+ if (DEBUG) {
+ System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice);
+ System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]);
+ System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES2[0]);
+ dumpMap();
}
return sr;
}
@@ -504,9 +583,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
@Override
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
- return null; // n/a for EGL .. since we don't keep the resources
+ return null; // FIXME: n/a ..
}
-
+
+ @Override
+ public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) {
+ SharedResource sr = getOrCreateEGLSharedResource(device);
+ if(null!=sr) {
+ return null != sr.getGLRendererQuirksES2() ? sr.getGLRendererQuirksES2() : sr.getGLRendererQuirksES1() ;
+ }
+ return null;
+ }
+
@Override
protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) {
SharedResource sr = getOrCreateEGLSharedResource(device);
@@ -596,9 +684,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
@Override
public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice,
GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) {
- final GLCapabilitiesImmutable chosenCaps =
- GLGraphicsConfigurationUtil.fixDoubleBufferedGLCapabilities(
- GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), false);
+ final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenBitOnly(requestedCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above
return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height));
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index e72255108..a2ac22fa5 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -247,9 +247,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
final GLProfile glp = capsChosen.getGLProfile();
- final EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory();
- capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(absDevice, glp), factory.canCreateGLPbuffer(absDevice) );
-
+ capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getEGLFactory(), absDevice);
EGLGraphicsConfiguration res = eglChooseConfig(eglDevice, capsChosen, capsReq, chooser, absScreen, nativeVisualID, forceTransparentFlag);
if(null==res) {
if(DEBUG) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index e174d38f4..06f8c0c25 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -45,7 +45,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.DefaultGraphicsScreen;
@@ -64,7 +63,6 @@ import javax.media.opengl.GLProfile;
import jogamp.nativewindow.WrappedSurface;
import jogamp.nativewindow.macosx.OSXDummyUpstreamSurfaceHook;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
-import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableFactoryImpl;
import jogamp.opengl.GLDrawableImpl;
import jogamp.opengl.GLDynamicLookupHelper;
@@ -148,7 +146,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
static class SharedResource {
// private MacOSXCGLDrawable drawable;
- // private MacOSXCGLContext context;
+ private MacOSXCGLContext context;
MacOSXGraphicsDevice device;
boolean wasContextCreated;
boolean hasNPOTTextures;
@@ -157,9 +155,9 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
SharedResource(MacOSXGraphicsDevice device, boolean wasContextCreated,
boolean hasNPOTTextures, boolean hasRECTTextures, boolean hasAppletFloatPixels
- /* MacOSXCGLDrawable draw, MacOSXCGLContext ctx */) {
+ /* MacOSXCGLDrawable draw */, MacOSXCGLContext ctx) {
// drawable = draw;
- // context = ctx;
+ this.context = ctx;
this.device = device;
this.wasContextCreated = wasContextCreated;
this.hasNPOTTextures = hasNPOTTextures;
@@ -167,6 +165,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
this.hasAppleFloatPixels = hasAppletFloatPixels;
}
final MacOSXGraphicsDevice getDevice() { return device; }
+ final MacOSXCGLContext getContext() { return context; }
final boolean wasContextAvailable() { return wasContextCreated; }
final boolean isNPOTTextureAvailable() { return hasNPOTTextures; }
final boolean isRECTTextureAvailable() { return hasRECTTextures; }
@@ -213,6 +212,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
if(null==sr && !getDeviceTried(connection)) {
addDeviceTried(connection);
final MacOSXGraphicsDevice sharedDevice = new MacOSXGraphicsDevice(adevice.getUnitID());
+ final MacOSXCGLContext sharedContext;
boolean madeCurrent = false;
boolean hasNPOTTextures = false;
boolean hasRECTTextures = false;
@@ -225,7 +225,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64));
sharedDrawable.setRealized(true);
- final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null);
+ sharedContext = (MacOSXCGLContext) sharedDrawable.createContext(null);
if (null == sharedContext) {
throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable);
}
@@ -256,7 +256,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
}
sharedDrawable.setRealized(false);
}
- sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels);
+ sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels, sharedContext);
synchronized(sharedMap) {
sharedMap.put(connection, sr);
}
@@ -293,7 +293,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
@Override
protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) {
- // FIXME: not implemented .. needs a dummy OSX surface
+ SharedResource sr = getOrCreateOSXSharedResource(device);
+ if(null!=sr) {
+ return sr.getContext();
+ }
return null;
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index 43a9d0d1a..3bbba2c52 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -35,7 +35,6 @@ package jogamp.opengl.macosx.cgl;
import jogamp.opengl.GLGraphicsConfigurationFactory;
import jogamp.opengl.GLGraphicsConfigurationUtil;
-import jogamp.opengl.x11.glx.X11GLXDrawableFactory;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.nativewindow.AbstractGraphicsDevice;
@@ -45,7 +44,6 @@ import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
@@ -91,10 +89,8 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati
if (absScreen == null) {
throw new IllegalArgumentException("AbstractGraphicsScreen is null");
}
- final MacOSXCGLDrawableFactory factory = (MacOSXCGLDrawableFactory) GLDrawableFactory.getDesktopFactory();
final AbstractGraphicsDevice device = absScreen.getDevice();
-
- capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(device) );
+ capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), device);
return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested);
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index d2d1dafc8..10d7fb22b 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -105,10 +105,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
}
final AbstractGraphicsDevice absDevice = absScreen.getDevice();
- final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
- capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities(
- capsChosen, GLContext.isFBOAvailable(absDevice, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(absDevice) );
-
+ capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), absDevice);
return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, (GLCapabilitiesChooser)chooser );
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 431706e24..ef2d3283d 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -45,7 +45,6 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
@@ -213,9 +212,9 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF
}
X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice();
X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory();
-
- capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(x11Device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(x11Device) );
- boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer();
+
+ capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory, x11Device);
+ final boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer();
X11GLXGraphicsConfiguration res = null;
if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) {