aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java5
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java9
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java17
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLCanvas.java10
-rw-r--r--src/jogl/classes/javax/media/opengl/awt/GLJPanel.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableHelper.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableImpl.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/awt/AWTUtil.java20
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLContext.java37
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java28
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java63
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java51
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java36
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java222
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java52
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java113
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java7
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java17
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java65
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java6
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java19
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java2
37 files changed, 515 insertions, 381 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
index 91f79793c..42097bd6d 100644
--- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
+++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java
@@ -45,7 +45,6 @@ import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
import javax.media.opengl.Threading;
-import jogamp.nativewindow.swt.SWTAccessor;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableHelper;
import jogamp.opengl.ThreadingImpl;
@@ -66,6 +65,7 @@ import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.util.VersionUtil;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
+import com.jogamp.nativewindow.swt.SWTAccessor;
import com.jogamp.opengl.JoglVersion;
/**
@@ -239,7 +239,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable {
drawable.setRealized(true);
context = drawable.createContext(shareWith);
-
+ context.setSynchronized(true);
+
/* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */
/* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */
addPaintListener(new PaintListener() {
diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
index 8d9d839e2..5b7ce4970 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java
@@ -301,10 +301,13 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE
//
public void destroy(GL gl) {
+ // super.destroy(gl):
+ // - GLArrayDataClient.destroy(gl): disables & clears client-side buffer
+ // - GLArrayDataWrapper.destroy(gl) (clears all values 'vboName' ..)
+ int _vboName = vboName;
super.destroy(gl);
- if(vboName!=0) {
- int[] tmp = new int[1];
- tmp[0] = vboName;
+ if(_vboName!=0) {
+ final int[] tmp = new int[] { _vboName } ;
gl.glDeleteBuffers(1, tmp, 0);
vboName = 0;
}
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 53b63cc0d..c039112c1 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -175,7 +175,7 @@ public abstract class GLContext {
/**
* Makes this GLContext current on the calling thread.
- *
+ * <p>
* There are two return values that indicate success and one that
* indicates failure. A return value of CONTEXT_CURRENT_NEW
* indicates that that context has been made current, and that
@@ -185,15 +185,22 @@ public abstract class GLContext {
* this case, the application may wish to initialize the state. A
* return value of CONTEXT_CURRENT indicates that the context has
* been made currrent, with its previous state restored.
- *
+ * </p>
+ * <p>
* If the context could not be made current (for example, because
* the underlying drawable has not ben realized on the display) ,
* a value of CONTEXT_NOT_CURRENT is returned.
- *
+ * </p>
+ * <p>
* If the context is in use by another thread at the time of the
* call, then if isSynchronized() is true the call will
* block. If isSynchronized() is false, an exception will be
* thrown and the context will remain current on the other thread.
+ * </p>
+ * <p>
+ * The drawable's surface is being locked at entry
+ * and unlocked at {@link #release()}
+ * </p>
*
* @return CONTEXT_CURRENT if the context was successfully made current
* @return CONTEXT_CURRENT_NEW if the context was successfully made
@@ -210,6 +217,10 @@ public abstract class GLContext {
/**
* Releases control of this GLContext from the current thread.
+ * <p>
+ * The drawable's surface is being unlocked at exit,
+ * assumed to be locked by {@link #makeCurrent()}.
+ * </p>
*
* @throws GLException if the context had not previously been made
* current on the current thread
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index da7051665..d8d9ddf6b 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -66,10 +66,6 @@ import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
-import javax.media.nativewindow.awt.AWTGraphicsDevice;
-import javax.media.nativewindow.awt.AWTGraphicsScreen;
-import javax.media.nativewindow.awt.AWTWindowClosingProtocol;
import javax.media.opengl.GL;
import javax.media.opengl.GLAnimatorControl;
@@ -88,12 +84,16 @@ import javax.media.opengl.Threading;
import com.jogamp.common.GlueGenVersion;
import com.jogamp.common.util.VersionUtil;
+import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
+import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
+import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
+import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
+import com.jogamp.nativewindow.awt.JAWTWindow;
import com.jogamp.opengl.JoglVersion;
import com.jogamp.common.util.locks.LockFactory;
import com.jogamp.common.util.locks.RecursiveLock;
-import jogamp.nativewindow.jawt.JAWTWindow;
import jogamp.opengl.Debug;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableHelper;
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
index cd9136e76..85ffae63e 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java
@@ -62,7 +62,6 @@ import javax.swing.JPanel;
import javax.media.nativewindow.WindowClosingProtocol;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.awt.AWTWindowClosingProtocol;
import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GL;
@@ -83,6 +82,7 @@ import javax.media.opengl.GLProfile;
import javax.media.opengl.GLRunnable;
import javax.media.opengl.Threading;
+import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol;
import com.jogamp.opengl.util.FBObject;
import com.jogamp.opengl.util.GLBuffers;
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
index e5f415a87..3c60eb699 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java
@@ -58,7 +58,8 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.MutableGraphicsConfiguration;
+import com.jogamp.nativewindow.MutableGraphicsConfiguration;
+
/** Extends GLDrawableFactory with a few methods for handling
typically software-accelerated offscreen rendering (Device
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
index 509839f55..c992b3cb2 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java
@@ -335,8 +335,11 @@ public class GLDrawableHelper {
desired goal is to be able to implement GLAutoDrawable's in terms of
the GLContext's public APIs, and putting it into a separate
class helps ensure that we don't inadvertently use private
- methods of the GLContext or its implementing classes.<br>
- * <br>
+ methods of the GLContext or its implementing classes.
+ <p>
+ Note: Locking of the surface is implicit done by {@link GLContext#makeCurrent()},
+ where unlocking is performed by the latter {@link GLContext#release()}.
+ </p>
*
* @param drawable
* @param context
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index 02a94f31c..36f17e5a1 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -148,7 +148,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
public final synchronized void setRealized(boolean realizedArg) {
if ( realized != realizedArg ) {
if(DEBUG) {
- System.err.println(getThreadName() + ": setRealized: "+getClass().getName()+" "+realized+" -> "+realizedArg);
+ System.err.println(getThreadName() + ": setRealized: "+getClass().getSimpleName()+" "+realized+" -> "+realizedArg);
}
realized = realizedArg;
AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice();
diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java b/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java
index 51143ab51..e15e538c2 100644
--- a/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java
+++ b/src/jogl/classes/jogamp/opengl/awt/AWTUtil.java
@@ -37,17 +37,15 @@
package jogamp.opengl.awt;
-import jogamp.nativewindow.jawt.*;
-
-import javax.media.opengl.*;
-
-import java.lang.reflect.*;
import java.awt.GraphicsEnvironment;
+import java.lang.reflect.Method;
+
+import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GLException;
public class AWTUtil {
// See whether we're running in headless mode
private static boolean headlessMode;
- private static Class j2dClazz = null;
private static Method isOGLPipelineActive = null;
private static Method isQueueFlusherThread = null;
private static boolean j2dOk = false;
@@ -57,7 +55,7 @@ public class AWTUtil {
headlessMode = GraphicsEnvironment.isHeadless();
if(!headlessMode) {
try {
- j2dClazz = Class.forName("jogamp.opengl.awt.Java2D");
+ final Class<?> j2dClazz = Class.forName("jogamp.opengl.awt.Java2D");
isOGLPipelineActive = j2dClazz.getMethod("isOGLPipelineActive", (Class[])null);
isQueueFlusherThread = j2dClazz.getMethod("isQueueFlusherThread", (Class[])null);
j2dOk = true;
@@ -84,12 +82,12 @@ public class AWTUtil {
try {
if( !((Boolean)isOGLPipelineActive.invoke(null, (Object[])null)).booleanValue() ||
!((Boolean)isQueueFlusherThread.invoke(null, (Object[])null)).booleanValue() ) {
- JAWTUtil.lockToolkit();
+ NativeWindowFactory.getAWTToolkitLock().lock();
}
} catch (Exception e) { j2dOk=false; }
}
if(!j2dOk) {
- JAWTUtil.lockToolkit();
+ NativeWindowFactory.getAWTToolkitLock().lock();
}
}
@@ -107,12 +105,12 @@ public class AWTUtil {
try {
if( !((Boolean)isOGLPipelineActive.invoke(null, (Object[])null)).booleanValue() ||
!((Boolean)isQueueFlusherThread.invoke(null, (Object[])null)).booleanValue() ) {
- JAWTUtil.unlockToolkit();
+ NativeWindowFactory.getAWTToolkitLock().unlock();
}
} catch (Exception e) { j2dOk=false; }
}
if(!j2dOk) {
- JAWTUtil.unlockToolkit();
+ NativeWindowFactory.getAWTToolkitLock().unlock();
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
index 9028f4377..dcef1cd3d 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java
@@ -37,6 +37,7 @@
package jogamp.opengl.egl;
import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
import java.util.Map;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
@@ -48,6 +49,7 @@ import javax.media.opengl.GLProfile;
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLDrawableImpl;
+import com.jogamp.common.nio.Buffers;
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
@@ -160,7 +162,7 @@ public abstract class EGLContext extends GLContextImpl {
try {
// might be unavailable on EGL < 1.2
if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) {
- throw new GLException("eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
+ throw new GLException("Catched: eglBindAPI to ES failed , error 0x"+Integer.toHexString(EGL.eglGetError()));
}
} catch (GLException glex) {
if (DEBUG) {
@@ -175,18 +177,22 @@ public abstract class EGLContext extends GLContextImpl {
}
}
- int[] contextAttrs = new int[] {
- EGL.EGL_CONTEXT_CLIENT_VERSION, -1,
- EGL.EGL_NONE
- };
- if (glProfile.usesNativeGLES2()) {
- contextAttrs[1] = 2;
- } else if (glProfile.usesNativeGLES1()) {
- contextAttrs[1] = 1;
- } else {
- throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile);
+ final IntBuffer contextAttrsNIO;
+ {
+ final int[] contextAttrs = new int[] {
+ EGL.EGL_CONTEXT_CLIENT_VERSION, -1,
+ EGL.EGL_NONE
+ };
+ if (glProfile.usesNativeGLES2()) {
+ contextAttrs[1] = 2;
+ } else if (glProfile.usesNativeGLES1()) {
+ contextAttrs[1] = 1;
+ } else {
+ throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile);
+ }
+ contextAttrsNIO = Buffers.newDirectIntBuffer(contextAttrs);
}
- contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrs, 0);
+ contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrsNIO);
if (contextHandle == 0) {
throw new GLException("Error creating OpenGL context: eglDisplay "+toHexString(eglDisplay)+
", eglConfig "+config+", "+glProfile+", shareWith "+toHexString(shareWithHandle)+", error "+toHexString(EGL.eglGetError()));
@@ -277,6 +283,13 @@ public abstract class EGLContext extends GLContextImpl {
public abstract void releasePbufferFromTexture();
+ protected static String toHexString(int hex) {
+ return GLContext.toHexString(hex);
+ }
+ protected static String toHexString(long hex) {
+ return GLContext.toHexString(hex);
+ }
+
//----------------------------------------------------------------------
// Currently unimplemented stuff
//
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
index 207a8e674..e09400c09 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java
@@ -30,6 +30,9 @@ package jogamp.opengl.egl;
import java.nio.IntBuffer;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.NativeWindowFactory;
+
import jogamp.opengl.Debug;
import com.jogamp.common.util.LongIntHashMap;
@@ -55,7 +58,30 @@ public class EGLDisplayUtil {
}
public static long eglGetDisplay(long nativeDisplay_id) {
- return EGL.eglGetDisplay(nativeDisplay_id);
+ final long eglDisplay = EGL.eglGetDisplay(nativeDisplay_id);
+ if(DEBUG) {
+ System.err.println("EGLDisplayUtil.eglGetDisplay(): eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+
+ EGLContext.toHexString(eglDisplay)+
+ ", "+((EGL.EGL_NO_DISPLAY != eglDisplay)?"OK":"Failed"));
+ }
+ return eglDisplay;
+ }
+
+ public static long eglGetDisplay(NativeSurface surface, boolean allowFallBackToDefault) {
+ final long nDisplay;
+ if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
+ nDisplay = surface.getSurfaceHandle(); // don't even ask ..
+ } else {
+ nDisplay = surface.getDisplayHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
+ }
+ long eglDisplay = EGLDisplayUtil.eglGetDisplay(nDisplay);
+ if (eglDisplay == EGL.EGL_NO_DISPLAY && nDisplay != EGL.EGL_DEFAULT_DISPLAY && allowFallBackToDefault) {
+ if(DEBUG) {
+ System.err.println("EGLDisplayUtil.eglGetDisplay(): Fall back to EGL_DEFAULT_DISPLAY");
+ }
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY);
+ }
+ return eglDisplay;
}
public static synchronized boolean eglInitialize(long eglDisplay, int[] major, int major_offset, int[] minor, int minor_offset) {
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
index 5c73b822c..b54089d13 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -40,9 +40,11 @@ import jogamp.opengl.GLDynamicLookupHelper;
import jogamp.opengl.GLDrawableImpl;
import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.*;
+import javax.media.nativewindow.VisualIDHolder.VIDType;
import javax.media.opengl.*;
+import com.jogamp.nativewindow.egl.*;
+
public abstract class EGLDrawable extends GLDrawableImpl {
protected boolean ownEGLDisplay = false; // for destruction
protected boolean ownEGLSurface = false; // for destruction
@@ -113,6 +115,13 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
}
+ @Override
+ protected final void updateHandle() {
+ if(ownEGLSurface) {
+ recreateSurface();
+ }
+ }
+
protected void setRealizedImpl() {
if (realized) {
AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration();
@@ -141,9 +150,8 @@ public abstract class EGLDrawable extends GLDrawableImpl {
System.err.println(getThreadName() + ": setSurface re-using component's EGLSurface: handle "+toHexString(eglSurface));
}
} else {
- // EGLSurface is ours ..
+ // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface();
ownEGLSurface=true;
- recreateSurface();
}
} else {
throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig);
@@ -157,43 +165,35 @@ public abstract class EGLDrawable extends GLDrawableImpl {
// EGLSurface is ours ..
ownEGLSurface=true;
- long nDisplay=0;
- if( NativeWindowFactory.TYPE_WINDOWS.equals(NativeWindowFactory.getNativeWindowType(false)) ) {
- nDisplay = surface.getSurfaceHandle(); // don't even ask ..
- } else {
- nDisplay = aDevice.getHandle(); // 0 == EGL.EGL_DEFAULT_DISPLAY
- }
- eglDisplay = EGLDisplayUtil.eglGetDisplay(nDisplay);
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- if(DEBUG) {
- System.err.println(getThreadName() + ": eglDisplay("+toHexString(nDisplay)+" <surfaceHandle>): failed, using EGL_DEFAULT_DISPLAY");
- }
- nDisplay = EGL.EGL_DEFAULT_DISPLAY;
- eglDisplay = EGLDisplayUtil.eglGetDisplay(nDisplay);
- }
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(surface, true);
if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Failed to created EGL display: nhandle "+toHexString(nDisplay)+", "+aDevice+", error "+toHexString(EGL.eglGetError()));
- } else if(DEBUG) {
- System.err.println(getThreadName() + ": eglDisplay("+toHexString(nDisplay)+"): "+toHexString(eglDisplay));
+ throw new GLException("Failed to created EGL display: "+surface+", "+aDevice+", error "+toHexString(EGL.eglGetError()));
}
if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) {
throw new GLException("eglInitialize failed"+", error "+Integer.toHexString(EGL.eglGetError()));
}
EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT);
- DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
- // use the original requested Capabilities, ignore previously chosen ones (x11,win32,..) - they are not fit
+ AbstractGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex());
final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities();
- eglConfig = (EGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(e).chooseGraphicsConfiguration(
- capsRequested, capsRequested, null, s);
- if (null == eglConfig) {
- throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
- } else if(DEBUG) {
- System.err.println(getThreadName() + ": Chosen eglConfig: "+eglConfig);
+ if(aConfig instanceof EGLGraphicsConfiguration) {
+ eglConfig = new EGLGraphicsConfiguration(s, (EGLGLCapabilities)aConfig.getChosenCapabilities(), capsRequested, null);
+ if(DEBUG) {
+ System.err.println(getThreadName() + ": Reusing chosenCaps: "+eglConfig);
+ }
+ } else {
+ eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
+ capsRequested, capsRequested, null, s, aConfig.getVisualID(VIDType.NATIVE));
+
+ if (null == eglConfig) {
+ throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s);
+ } else if(DEBUG) {
+ System.err.println(getThreadName() + ": Chosen eglConfig: "+eglConfig);
+ }
}
- recreateSurface();
+ // subsequent updateHandle() will issue recreateSurface();
}
if(DEBUG) {
- System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface+" - "+this);
+ System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface);
}
} else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) {
if(DEBUG) {
@@ -205,9 +205,6 @@ public abstract class EGLDrawable extends GLDrawableImpl {
}
eglSurface = EGL.EGL_NO_SURFACE;
if (ownEGLDisplay && EGL.EGL_NO_DISPLAY!=eglDisplay) {
- if(DEBUG) {
- System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): eglTerminate: "+toHexString(eglDisplay));
- }
EGLDisplayUtil.eglTerminate(eglDisplay);
}
eglDisplay=EGL.EGL_NO_DISPLAY;
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
index bee2b28f9..14cf83f56 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java
@@ -37,15 +37,15 @@
package jogamp.opengl.egl;
import javax.media.nativewindow.*;
-import javax.media.nativewindow.egl.EGLGraphicsDevice;
import javax.media.opengl.*;
import javax.media.opengl.GLProfile.ShutdownType;
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.*;
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
import jogamp.opengl.*;
-import jogamp.nativewindow.WrappedSurface;
import java.util.Collection;
import java.util.HashMap;
@@ -151,7 +151,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
if(DEBUG) {
System.err.println("EGLDrawableFactory.destroy("+shutdownType+"): "+sr.device.toString());
}
- EGLDisplayUtil.eglTerminate(sr.device.getHandle());
+ final long eglDisplay = sr.device.getHandle();
+ if(EGL.EGL_NO_DISPLAY != eglDisplay) {
+ EGLDisplayUtil.eglTerminate(eglDisplay);
+ }
}
sharedMap.clear();
sharedMap = null;
@@ -355,7 +358,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl {
// FIXME device/windowHandle -> screen ?!
EGLGraphicsDevice device = (EGLGraphicsDevice) adevice;
DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0);
- EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, -1);
+ EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED);
WrappedSurface ns = new WrappedSurface(cfg, windowHandle);
return ns;
}
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index bd5eb1b99..2e1793d72 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -28,44 +28,30 @@
package jogamp.opengl.egl;
-import java.util.Comparator;
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
+
public class EGLGLCapabilities extends GLCapabilities {
- final long eglcfg;
- final int eglcfgid;
- final int renderableType;
- int nativeVisualID;
+ final private long eglcfg;
+ final private int eglcfgid;
+ final private int renderableType;
+ final private int nativeVisualID;
- /** Comparing EGLConfig ID only */
- public static class EglCfgIDComparator implements Comparator<EGLGLCapabilities> {
-
- public int compare(EGLGLCapabilities caps1, EGLGLCapabilities caps2) {
- final long id1 = caps1.getEGLConfigID();
-
- final long id2 = caps2.getEGLConfigID();
-
- if(id1 > id2) {
- return 1;
- } else if(id1 < id2) {
- return -1;
- }
- return 0;
- }
- }
-
/**
*
* @param eglcfg
* @param eglcfgid
+ * @param visualID native visualID if valid, otherwise VisualIDHolder.VID_UNDEFINED
* @param glp desired GLProfile, or null if determined by renderableType
* @param renderableType actual EGL renderableType
*
* May throw GLException if given GLProfile is not compatible w/ renderableType
*/
- public EGLGLCapabilities(long eglcfg, int eglcfgid, GLProfile glp, int renderableType) {
+ public EGLGLCapabilities(long eglcfg, int eglcfgid, int visualID, GLProfile glp, int renderableType) {
super( ( null != glp ) ? glp : getCompatible(renderableType) );
this.eglcfg = eglcfg;
this.eglcfgid = eglcfgid;
@@ -74,6 +60,7 @@ public class EGLGLCapabilities extends GLCapabilities {
" with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]");
}
this.renderableType = renderableType;
+ this.nativeVisualID = visualID;
}
public Object cloneMutable() {
@@ -91,9 +78,21 @@ public class EGLGLCapabilities extends GLCapabilities {
final public long getEGLConfig() { return eglcfg; }
final public int getEGLConfigID() { return eglcfgid; }
final public int getRenderableType() { return renderableType; }
- final public void setNativeVisualID(int vid) { nativeVisualID=vid; }
final public int getNativeVisualID() { return nativeVisualID; }
+ @Override
+ final public int getVisualID(VIDType type) throws NativeWindowException {
+ switch(type) {
+ case INTRINSIC:
+ case EGL_CONFIG:
+ return getEGLConfigID();
+ case NATIVE:
+ return getNativeVisualID();
+ default:
+ throw new NativeWindowException("Invalid type <"+type+">");
+ }
+ }
+
public static boolean isCompatible(GLProfile glp, int renderableType) {
if(null == glp) {
return true;
@@ -147,8 +146,8 @@ public class EGLGLCapabilities extends GLCapabilities {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append("0x").append(Long.toHexString(eglcfgid)).append(": ");
- sink.append("vid 0x").append(Integer.toHexString(nativeVisualID)).append(", ");
+ sink.append("egl cfg 0x").append(Integer.toHexString(eglcfgid));
+ sink.append(", vid 0x").append(Integer.toHexString(nativeVisualID)).append(": ");
super.toString(sink);
sink.append(", [");
renderableTypeToString(sink, renderableType);
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
index 2f486140f..35e30c5f4 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -42,23 +42,22 @@ import java.util.ArrayList;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.egl.EGLGraphicsDevice;
+import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.MutableGraphicsConfiguration;
-import jogamp.opengl.Debug;
import jogamp.opengl.GLGraphicsConfigurationUtil;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.nativewindow.MutableGraphicsConfiguration;
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
- protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
-
+
public final long getNativeConfig() {
return ((EGLGLCapabilities)capabilitiesChosen).getEGLConfig();
}
@@ -172,6 +171,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
final IntBuffer val = Buffers.newDirectIntBuffer(1);
final int cfgID;
final int rType;
+ final int visualID;
// get the configID
if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) {
@@ -190,10 +190,16 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
return false;
}
rType = val.get(0);
+
+ if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_NATIVE_VISUAL_ID, val)) {
+ visualID = val.get(0);
+ } else {
+ visualID = VisualIDHolder.VID_UNDEFINED;
+ }
EGLGLCapabilities caps = null;
try {
- caps = new EGLGLCapabilities(config, cfgID, glp, rType);
+ caps = new EGLGLCapabilities(config, cfgID, visualID, glp, rType);
} catch (GLException gle) {
if(DEBUG) {
System.err.println("config "+toHexString(config)+": "+gle);
@@ -201,10 +207,6 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
return false;
}
- // Read the actual configuration into the chosen caps
- if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_NATIVE_VISUAL_ID, val)) {
- caps.setNativeVisualID(val.get(0));
- }
if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val)) {
caps.setRedBits(val.get(0));
}
@@ -275,11 +277,15 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple
attrs[idx++] = EGL.EGL_BLUE_SIZE;
attrs[idx++] = caps.getBlueBits();
- attrs[idx++] = EGL.EGL_ALPHA_SIZE;
- attrs[idx++] = caps.getAlphaBits() > 0 ? caps.getAlphaBits() : EGL.EGL_DONT_CARE;
-
- attrs[idx++] = EGL.EGL_STENCIL_SIZE;
- attrs[idx++] = caps.getStencilBits() > 0 ? caps.getStencilBits() : EGL.EGL_DONT_CARE;
+ if(caps.getAlphaBits()>0) {
+ attrs[idx++] = EGL.EGL_ALPHA_SIZE;
+ attrs[idx++] = caps.getAlphaBits();
+ }
+
+ if(caps.getStencilBits()>0) {
+ attrs[idx++] = EGL.EGL_STENCIL_SIZE;
+ attrs[idx++] = caps.getStencilBits();
+ }
attrs[idx++] = EGL.EGL_DEPTH_SIZE;
attrs[idx++] = caps.getDepthBits();
diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
index ceeebe60b..2d9fc0227 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -40,7 +40,9 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.egl.EGLGraphicsDevice;
+import javax.media.nativewindow.VisualIDHolder;
+import javax.media.nativewindow.VisualIDHolder.VIDType;
+import javax.media.nativewindow.NativeWindowFactory;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
@@ -51,9 +53,11 @@ import javax.media.opengl.GLDrawableFactory;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.nativewindow.egl.EGLGraphicsDevice;
import jogamp.opengl.GLGraphicsConfigurationFactory;
import jogamp.opengl.GLGraphicsConfigurationUtil;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -67,12 +71,25 @@ import java.nio.IntBuffer;
GraphicsDevice and GraphicsConfiguration abstractions. */
public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
- static EGLGLCapabilities.EglCfgIDComparator EglCfgIDComparator = new EGLGLCapabilities.EglCfgIDComparator();
-
+ static VisualIDHolder.VIDComparator EglCfgIDComparator = new VisualIDHolder.VIDComparator(VisualIDHolder.VIDType.EGL_CONFIG);
+ static GraphicsConfigurationFactory nativeGraphicsConfigurationFactory = null;
+
static void registerFactory() {
+ GraphicsConfigurationFactory eglFactory = new EGLGraphicsConfigurationFactory();
+
+ // become the pre-selector for X11/.. to match the native visual id w/ EGL, if native ES is selected
+ final String nwType = NativeWindowFactory.getNativeWindowType(false);
+ if(NativeWindowFactory.TYPE_X11 == nwType) {
+ nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, eglFactory);
+ } /* else if(NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false)) {
+ nativeGraphicsConfigurationFactory = GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, eglFactory);
+ } else if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)) {
+ } */
+
// become the selector for KD/EGL ..
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.egl.EGLGraphicsDevice.class, new EGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, eglFactory);
}
+
private EGLGraphicsConfigurationFactory() {
}
@@ -86,6 +103,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if (! (capsChosen instanceof GLCapabilitiesImmutable) ) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - chosen");
}
+ final GLCapabilitiesImmutable glCapsChosen = (GLCapabilitiesImmutable) capsChosen;
if (! (capsRequested instanceof GLCapabilitiesImmutable) ) {
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilities objects - requested");
@@ -96,10 +114,48 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new IllegalArgumentException("This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
}
- return chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
- (GLCapabilitiesImmutable) capsRequested,
- (GLCapabilitiesChooser) chooser,
- absScreen, -1);
+ AbstractGraphicsDevice absDevice = absScreen.getDevice();
+ if(null==absDevice) {
+ throw new GLException("Null AbstractGraphicsDevice");
+ }
+
+ AbstractGraphicsConfiguration cfg = null;
+
+ if( absDevice instanceof EGLGraphicsDevice ) {
+ cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
+ (GLCapabilitiesImmutable) capsRequested,
+ (GLCapabilitiesChooser) chooser,
+ absScreen, VisualIDHolder.VID_UNDEFINED);
+ } else {
+ // handle non native cases (X11, ..)
+ if(null == nativeGraphicsConfigurationFactory) {
+ throw new InternalError("Native GraphicsConfigurationFactory is null, but call issued for device: "+absDevice+" of type "+absDevice.getClass().getSimpleName());
+ }
+
+ if(glCapsChosen.getGLProfile().usesNativeGLES()) {
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfigurationFactory.choose..: Handle native device "+absDevice.getClass().getSimpleName());
+ }
+ cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen,
+ (GLCapabilitiesImmutable) capsRequested,
+ (GLCapabilitiesChooser) chooser,
+ absScreen, VisualIDHolder.VID_UNDEFINED);
+ if(null == cfg || VisualIDHolder.VID_UNDEFINED == cfg.getVisualID(VIDType.NATIVE)) {
+ cfg = null;
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfigurationFactory.choose..: No native visual ID, fallback ..");
+ }
+ }
+ }
+ if(null == cfg) {
+ // fwd to native config factory (only X11 for now)
+ if(DEBUG) {
+ System.err.println("EGLGraphicsConfigurationFactory.choose..: Delegate to "+nativeGraphicsConfigurationFactory.getClass().getSimpleName());
+ }
+ cfg = nativeGraphicsConfigurationFactory.chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, absScreen);
+ }
+ }
+ return cfg;
}
protected static List<GLCapabilitiesImmutable> getAvailableCapabilities(EGLDrawableFactory factory, AbstractGraphicsDevice device) {
@@ -147,79 +203,91 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
throw new GLException("Null AbstractGraphicsScreen");
}
AbstractGraphicsDevice absDevice = absScreen.getDevice();
-
- if(null==absDevice || !(absDevice instanceof EGLGraphicsDevice)) {
- throw new GLException("GraphicsDevice must be a valid EGLGraphicsDevice");
+ if(null==absDevice) {
+ throw new GLException("Null AbstractGraphicsDevice");
}
- long eglDisplay = absDevice.getHandle();
-
- if (eglDisplay == EGL.EGL_NO_DISPLAY) {
- throw new GLException("Invalid EGL display: "+absDevice);
+
+ final long eglDisplay;
+ final boolean ownEGLDisplay;
+ if( !(absDevice instanceof EGLGraphicsDevice) ) {
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(absDevice.getHandle());
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Could not get EGL display from: "+absDevice);
+ }
+ if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) {
+ throw new GLException("eglInitialize failed eglDisplay 0x"+Long.toHexString(eglDisplay)+", "+absDevice+", error 0x"+Integer.toHexString(EGL.eglGetError()));
+ }
+ ownEGLDisplay = true;
+ } else {
+ eglDisplay = absDevice.getHandle();
+ if (eglDisplay == EGL.EGL_NO_DISPLAY) {
+ throw new GLException("Invalid EGL display: "+absDevice);
+ }
+ ownEGLDisplay = false;
}
EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory();
capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory.canCreateGLPbuffer(absDevice) );
GLProfile glp = capsChosen.getGLProfile();
+ GLCapabilities fixedCaps;
EGLGraphicsConfiguration res = eglChooseConfig(eglDisplay, capsChosen, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
- }
- if(DEBUG) {
- System.err.println("eglChooseConfig failed with given capabilities "+capsChosen);
- }
-
- // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..]
- //
- // rgb888 - d16, s4
- GLCapabilities fixedCaps = new GLCapabilities(glp);
- fixedCaps.setRedBits(8);
- fixedCaps.setGreenBits(8);
- fixedCaps.setBlueBits(8);
- fixedCaps.setDepthBits(16);
- fixedCaps.setSampleBuffers(true);
- fixedCaps.setNumSamples(4);
- if(DEBUG) {
- System.err.println("trying fixed caps (1): "+fixedCaps);
- }
- res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
+ if(null==res) {
+ if(DEBUG) {
+ System.err.println("eglChooseConfig failed with given capabilities "+capsChosen);
+ }
+
+ // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..]
+ //
+ // rgb888 - d16, s4
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(8);
+ fixedCaps.setGreenBits(8);
+ fixedCaps.setBlueBits(8);
+ fixedCaps.setDepthBits(16);
+ fixedCaps.setSampleBuffers(true);
+ fixedCaps.setNumSamples(4);
+ if(DEBUG) {
+ System.err.println("trying fixed caps (1): "+fixedCaps);
+ }
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
+ }
+ if(null==res) {
+ //
+ // rgb565 - d16, s0
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(5);
+ fixedCaps.setGreenBits(6);
+ fixedCaps.setBlueBits(5);
+ fixedCaps.setDepthBits(16);
+ if(DEBUG) {
+ System.err.println("trying fixed caps (2): "+fixedCaps);
+ }
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
+ }
+ if(null==res) {
+ //
+ // rgb565 - d16, s4
+ fixedCaps = new GLCapabilities(glp);
+ fixedCaps.setRedBits(5);
+ fixedCaps.setGreenBits(6);
+ fixedCaps.setBlueBits(5);
+ fixedCaps.setDepthBits(16);
+ fixedCaps.setSampleBuffers(true);
+ fixedCaps.setNumSamples(4);
+ if(DEBUG) {
+ System.err.println("trying fixed caps (3): "+fixedCaps);
+ }
+ res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
}
-
- //
- // rgb565 - d16, s0
- fixedCaps = new GLCapabilities(glp);
- fixedCaps.setRedBits(5);
- fixedCaps.setGreenBits(6);
- fixedCaps.setBlueBits(5);
- fixedCaps.setDepthBits(16);
- if(DEBUG) {
- System.err.println("trying fixed caps (2): "+fixedCaps);
- }
- res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
- }
-
- //
- // rgb565 - d16, s4
- fixedCaps = new GLCapabilities(glp);
- fixedCaps.setRedBits(5);
- fixedCaps.setGreenBits(6);
- fixedCaps.setBlueBits(5);
- fixedCaps.setDepthBits(16);
- fixedCaps.setSampleBuffers(true);
- fixedCaps.setNumSamples(4);
- if(DEBUG) {
- System.err.println("trying fixed caps (3): "+fixedCaps);
+ if(null==res) {
+ throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps(1-3)]");
}
- res = eglChooseConfig(eglDisplay, fixedCaps, capsReq, chooser, absScreen, nativeVisualID);
- if(null!=res) {
- return res;
+ if(ownEGLDisplay) {
+ EGLDisplayUtil.eglTerminate(eglDisplay);
}
- throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps(1-3)]");
+ return res;
}
static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay,
@@ -244,7 +312,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
if (DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig maxConfigs: "+numConfigs.get(0));
- System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen);
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen+", nativeVisualID "+toHexString(nativeVisualID));
}
final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen));
@@ -253,7 +321,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
// 1st choice: get GLCapabilities based on users GLCapabilities
// setting recommendedIndex as preferred choice
// skipped if nativeVisualID is given
- if( 0<=nativeVisualID || !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) {
+ if( VisualIDHolder.VID_UNDEFINED != nativeVisualID || !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) {
if(DEBUG) {
System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false");
}
@@ -302,11 +370,11 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
}
- if(0<=nativeVisualID) {
+ if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) {
List/*<EGLGLCapabilities>*/ removedCaps = new ArrayList();
for(int i=0; i<availableCaps.size(); ) {
- EGLGLCapabilities ecap = (EGLGLCapabilities) availableCaps.get(i);
- if(ecap.getNativeVisualID()!=nativeVisualID) {
+ VisualIDHolder vidh = (VisualIDHolder) availableCaps.get(i);
+ if(vidh.getVisualID(VIDType.NATIVE) != nativeVisualID) {
removedCaps.add(availableCaps.remove(i));
} else {
i++;
@@ -315,10 +383,10 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
if(0==availableCaps.size()) {
availableCaps = removedCaps;
if(DEBUG) {
- System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID ("+nativeVisualID+") no config found, revert to all");
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID "+toHexString(nativeVisualID)+" no config found, revert to all");
}
} else if(DEBUG) {
- System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID ("+nativeVisualID+") got configs: "+availableCaps.size());
+ System.err.println("EGLGraphicsConfiguration.eglChooseConfig: post filter nativeVisualID "+toHexString(nativeVisualID)+" got configs: "+availableCaps.size());
}
}
@@ -363,7 +431,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact
}
DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0);
- EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, screen, -1);
+ EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, screen, VisualIDHolder.VID_UNDEFINED);
if (null == eglConfig) {
throw new GLException("Couldn't create EGLGraphicsConfiguration from "+screen);
} else 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 5327f7bf5..b696e1ba3 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -52,7 +52,6 @@ import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
@@ -63,7 +62,6 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLProfile.ShutdownType;
-import jogamp.nativewindow.WrappedSurface;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
import jogamp.opengl.GLDrawableFactoryImpl;
import jogamp.opengl.GLDrawableImpl;
@@ -71,6 +69,8 @@ import jogamp.opengl.GLDynamicLookupHelper;
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.ReflectionUtil;
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice;
public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
private static DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper = null;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
index efab37e1b..8393a688e 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java
@@ -46,9 +46,9 @@ import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.MutableGraphicsConfiguration;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.nativewindow.MutableGraphicsConfiguration;
public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
long pixelformat;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
index 7f15062a7..1a9070aef 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java
@@ -50,7 +50,7 @@ import javax.media.opengl.GLCapabilitiesImmutable;
public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
static void registerFactory() {
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.macosx.MacOSXGraphicsDevice.class, new MacOSXCGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice.class, new MacOSXCGLGraphicsConfigurationFactory());
}
private MacOSXCGLGraphicsConfigurationFactory() {
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
index 0e54b09ec..58cea4ade 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java
@@ -49,7 +49,8 @@ import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
-import jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.WrappedSurface;
+
import jogamp.opengl.GLContextImpl;
import jogamp.opengl.GLContextShareSet;
import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType;
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
index c0d6fe686..a6fa01bad 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXAWTCGLGraphicsConfigurationFactory.java
@@ -44,20 +44,21 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
-import javax.media.nativewindow.awt.AWTGraphicsDevice;
-import javax.media.nativewindow.awt.AWTGraphicsScreen;
-import javax.media.nativewindow.macosx.MacOSXGraphicsDevice;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLException;
+import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
+import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
+import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
+import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice;
+
import jogamp.opengl.macosx.cgl.MacOSXCGLGraphicsConfiguration;
public class MacOSXAWTCGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
public static void registerFactory() {
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new MacOSXAWTCGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new MacOSXAWTCGLGraphicsConfigurationFactory());
}
private MacOSXAWTCGLGraphicsConfigurationFactory() {
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index adfddddcd..24bc5aea6 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -28,47 +28,19 @@
package jogamp.opengl.windows.wgl;
-import java.util.Comparator;
-
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
+
+import javax.media.nativewindow.NativeWindowException;
import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
public class WGLGLCapabilities extends GLCapabilities {
- final PIXELFORMATDESCRIPTOR pfd;
- final int pfdID;
- int arb_pixelformat; // -1 PFD, 0 NOP, 1 ARB
-
- /** Comparing pfd id only */
- public static class PfdIDComparator implements Comparator {
-
- public int compare(Object o1, Object o2) {
- if ( ! ( o1 instanceof WGLGLCapabilities ) ) {
- Class c = (null != o1) ? o1.getClass() : null ;
- throw new ClassCastException("arg1 not a WGLGLCapabilities object: " + c);
- }
- if ( ! ( o2 instanceof WGLGLCapabilities ) ) {
- Class c = (null != o2) ? o2.getClass() : null ;
- throw new ClassCastException("arg2 not a WGLGLCapabilities object: " + c);
- }
-
- final WGLGLCapabilities caps1 = (WGLGLCapabilities) o1;
- final long id1 = caps1.getPFDID();
-
- final WGLGLCapabilities caps2 = (WGLGLCapabilities) o2;
- final long id2 = caps2.getPFDID();
-
- if(id1 > id2) {
- return 1;
- } else if(id1 < id2) {
- return -1;
- }
- return 0;
- }
- }
+ final private PIXELFORMATDESCRIPTOR pfd;
+ final private int pfdID;
+ private int arb_pixelformat; // -1 PFD, 0 NOP, 1 ARB
public WGLGLCapabilities(PIXELFORMATDESCRIPTOR pfd, int pfdID, GLProfile glp) {
super(glp);
@@ -224,11 +196,23 @@ public class WGLGLCapabilities extends GLCapabilities {
final public boolean isSetByGDI() { return 0 > arb_pixelformat; }
final public boolean isSet() { return 0 != arb_pixelformat; }
+ @Override
+ final public int getVisualID(VIDType type) throws NativeWindowException {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ case WIN32_PFD:
+ return getPFDID();
+ default:
+ throw new NativeWindowException("Invalid type <"+type+">");
+ }
+ }
+
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append(pfdID).append(" ");
+ sink.append("wgl vid 0x").append(Integer.toHexString(pfdID)).append(" ");
switch (arb_pixelformat) {
case -1:
sink.append("gdi");
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
index 2835c00d3..745782085 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java
@@ -50,7 +50,8 @@ import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.WrappedSurface;
+
import jogamp.nativewindow.windows.GDI;
import jogamp.opengl.GLContextShareSet;
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java
index 1e5991821..ad2e91bed 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java
@@ -49,7 +49,8 @@ import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.WrappedSurface;
+
import jogamp.nativewindow.windows.GDI;
public class WindowsExternalWGLDrawable extends WindowsWGLDrawable {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
index 9ddab4239..51566d48d 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -50,10 +50,9 @@ import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.ProxySurface;
import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.windows.WindowsGraphicsDevice;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
+import javax.media.nativewindow.ProxySurface;
import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLCapabilitiesChooser;
@@ -68,8 +67,9 @@ import com.jogamp.common.nio.PointerBuffer;
import com.jogamp.common.os.Platform;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionNumber;
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.windows.WindowsGraphicsDevice;
-import jogamp.nativewindow.WrappedSurface;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.GDIUtil;
import jogamp.nativewindow.windows.GDISurface;
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index cdb930280..5682b35e8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -47,17 +47,15 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
-import jogamp.nativewindow.MutableGraphicsConfiguration;
+import com.jogamp.nativewindow.MutableGraphicsConfiguration;
+
import jogamp.nativewindow.windows.DWM_BLURBEHIND;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.MARGINS;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
import jogamp.opengl.GLGraphicsConfigurationUtil;
-public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
- // Keep this under the same debug flag as the drawable factory for convenience
- protected static final boolean DEBUG = jogamp.opengl.Debug.debug("GraphicsConfiguration");
-
+public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
protected static final int MAX_PFORMATS = 256;
protected static final int MAX_ATTRIBS = 256;
@@ -456,18 +454,22 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio
iattributes[niattribs++] = GL.GL_FALSE;
}
- iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
- iattributes[niattribs++] = caps.getDepthBits();
iattributes[niattribs++] = WGLExt.WGL_RED_BITS_ARB;
iattributes[niattribs++] = caps.getRedBits();
iattributes[niattribs++] = WGLExt.WGL_GREEN_BITS_ARB;
iattributes[niattribs++] = caps.getGreenBits();
iattributes[niattribs++] = WGLExt.WGL_BLUE_BITS_ARB;
iattributes[niattribs++] = caps.getBlueBits();
- iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
- iattributes[niattribs++] = caps.getAlphaBits();
- iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
- iattributes[niattribs++] = caps.getStencilBits();
+ if(caps.getAlphaBits()>0) {
+ iattributes[niattribs++] = WGLExt.WGL_ALPHA_BITS_ARB;
+ iattributes[niattribs++] = caps.getAlphaBits();
+ }
+ if(caps.getStencilBits()>0) {
+ iattributes[niattribs++] = WGLExt.WGL_STENCIL_BITS_ARB;
+ iattributes[niattribs++] = caps.getStencilBits();
+ }
+ iattributes[niattribs++] = WGLExt.WGL_DEPTH_BITS_ARB;
+ iattributes[niattribs++] = caps.getDepthBits();
if (caps.getAccumRedBits() > 0 ||
caps.getAccumGreenBits() > 0 ||
caps.getAccumBlueBits() > 0 ||
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index abfb17a0c..4681a6ef7 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -42,6 +42,7 @@ import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLContext;
@@ -64,10 +65,10 @@ import java.util.List;
GraphicsDevice and GraphicsConfiguration abstractions. */
public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
- static WGLGLCapabilities.PfdIDComparator PfdIDComparator = new WGLGLCapabilities.PfdIDComparator();
+ static VisualIDHolder.VIDComparator PfdIDComparator = new VisualIDHolder.VIDComparator(VisualIDHolder.VIDType.WIN32_PFD);
static void registerFactory() {
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.windows.WindowsGraphicsDevice.class, new WindowsWGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.windows.WindowsGraphicsDevice.class, new WindowsWGLGraphicsConfigurationFactory());
}
private WindowsWGLGraphicsConfigurationFactory() {
}
@@ -230,6 +231,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
if (config == null) {
throw new IllegalArgumentException("WindowsWGLGraphicsConfiguration is null");
}
+ if ( !(_factory instanceof WindowsWGLDrawableFactory) ) {
+ throw new GLException("GLDrawableFactory is not a WindowsWGLDrawableFactory, but: "+_factory.getClass().getSimpleName());
+ }
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory) _factory;
WindowsWGLDrawable sharedDrawable = factory.getOrCreateSharedDrawable(device);
if(null == sharedDrawable) {
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
index 5cd783221..bd64b58a4 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -35,6 +35,11 @@ package jogamp.opengl.windows.wgl.awt;
import com.jogamp.common.util.ArrayHashSet;
+import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
+import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
+import com.jogamp.nativewindow.awt.AWTGraphicsScreen;
+import com.jogamp.nativewindow.windows.WindowsGraphicsDevice;
+
import jogamp.nativewindow.jawt.windows.Win32SunJDKReflection;
import jogamp.opengl.GLGraphicsConfigurationFactory;
import java.awt.GraphicsConfiguration;
@@ -47,21 +52,18 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.awt.AWTGraphicsConfiguration;
-import javax.media.nativewindow.awt.AWTGraphicsDevice;
-import javax.media.nativewindow.awt.AWTGraphicsScreen;
-import javax.media.nativewindow.windows.WindowsGraphicsDevice;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLException;
+import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory;
import jogamp.opengl.windows.wgl.WindowsWGLGraphicsConfiguration;
import javax.media.opengl.GLDrawableFactory;
public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
public static void registerFactory() {
- GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new WindowsAWTWGLGraphicsConfigurationFactory());
+ GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new WindowsAWTWGLGraphicsConfigurationFactory());
}
private WindowsAWTWGLGraphicsConfigurationFactory() {
}
@@ -104,8 +106,6 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
WindowsGraphicsDevice winDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
GraphicsConfigurationFactory configFactory = GraphicsConfigurationFactory.getFactory(winDevice);
- GLDrawableFactory drawableFactory = GLDrawableFactory.getFactory( ((GLCapabilitiesImmutable)capsChosen).getGLProfile() );
-
WindowsWGLGraphicsConfiguration winConfig = (WindowsWGLGraphicsConfiguration)
configFactory.chooseGraphicsConfiguration(capsChosen,
capsRequested,
@@ -114,61 +114,68 @@ public class WindowsAWTWGLGraphicsConfigurationFactory extends GLGraphicsConfigu
throw new GLException("Unable to choose a GraphicsConfiguration: "+capsChosen+",\n\t"+chooser+"\n\t"+winScreen);
}
+ GLDrawableFactory drawableFactory = GLDrawableFactory.getFactory(((GLCapabilitiesImmutable)capsChosen).getGLProfile());
GraphicsConfiguration chosenGC = null;
- // 1st Choice: Create an AWT GraphicsConfiguration with the desired PFD
- // This gc will probably not be able to support GDI (WGL_SUPPORT_GDI_ARB, PFD_SUPPORT_GDI)
- // however on most GPUs this is the current situation for Windows,
- // otherwise no hardware accelerated PFD could be achieved.
- // - preselect with no constrains
- // - try to create dedicated GC
- try {
- winConfig.preselectGraphicsConfiguration(drawableFactory, null);
- if ( 1 <= winConfig.getPixelFormatID() ) {
- chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
- if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ if ( drawableFactory instanceof WindowsWGLDrawableFactory ) {
+ // 1st Choice: Create an AWT GraphicsConfiguration with the desired PFD
+ // This gc will probably not be able to support GDI (WGL_SUPPORT_GDI_ARB, PFD_SUPPORT_GDI)
+ // however on most GPUs this is the current situation for Windows,
+ // otherwise no hardware accelerated PFD could be achieved.
+ // - preselect with no constrains
+ // - try to create dedicated GC
+ try {
+ winConfig.preselectGraphicsConfiguration(drawableFactory, null);
+ if ( 1 <= winConfig.getPixelFormatID() ) {
+ chosenGC = Win32SunJDKReflection.graphicsConfigurationGet(device, winConfig.getPixelFormatID());
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found new AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ }
}
- }
- } catch (GLException gle0) {
- gle0.printStackTrace();
- // go on ..
- }
-
- if( null == chosenGC ) {
- // 2nd Choice: Choose and match the GL Visual with AWT:
- // - collect all AWT PFDs
- // - choose a GL config from the pool of AWT PFDs
- //
- // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer,
- // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
- //
-
- // collect all available PFD IDs
- GraphicsConfiguration[] configs = device.getConfigurations();
- int[] pfdIDs = new int[configs.length];
- ArrayHashSet pfdIDOSet = new ArrayHashSet();
- for (int i = 0; i < configs.length; i++) {
- GraphicsConfiguration gc = configs[i];
- pfdIDs[i] = Win32SunJDKReflection.graphicsConfigurationGetPixelFormatID(gc);
- pfdIDOSet.add(new Integer(pfdIDs[i]));
+ } catch (GLException gle0) {
if(DEBUG) {
- System.err.println("AWT pfd["+i+"] "+pfdIDs[i]);
+ gle0.printStackTrace();
}
+ // go on ..
}
- if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: PFD IDs: "+pfdIDs.length+", unique: "+pfdIDOSet.size());
- }
- winConfig.preselectGraphicsConfiguration(drawableFactory, pfdIDs);
- int gcIdx = pfdIDOSet.indexOf(new Integer(winConfig.getPixelFormatID()));
- if( 0 > gcIdx ) {
- chosenGC = configs[gcIdx];
+
+ if( null == chosenGC ) {
+ // 2nd Choice: Choose and match the GL Visual with AWT:
+ // - collect all AWT PFDs
+ // - choose a GL config from the pool of AWT PFDs
+ //
+ // The resulting GraphicsConfiguration has to be 'forced' on the AWT native peer,
+ // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify().
+ //
+
+ // collect all available PFD IDs
+ GraphicsConfiguration[] configs = device.getConfigurations();
+ int[] pfdIDs = new int[configs.length];
+ ArrayHashSet<Integer> pfdIDOSet = new ArrayHashSet<Integer>();
+ for (int i = 0; i < configs.length; i++) {
+ GraphicsConfiguration gc = configs[i];
+ pfdIDs[i] = Win32SunJDKReflection.graphicsConfigurationGetPixelFormatID(gc);
+ pfdIDOSet.add(new Integer(pfdIDs[i]));
+ if(DEBUG) {
+ System.err.println("AWT pfd["+i+"] "+pfdIDs[i]);
+ }
+ }
if(DEBUG) {
- System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: PFD IDs: "+pfdIDs.length+", unique: "+pfdIDOSet.size());
}
- }
+ winConfig.preselectGraphicsConfiguration(drawableFactory, pfdIDs);
+ int gcIdx = pfdIDOSet.indexOf(new Integer(winConfig.getPixelFormatID()));
+ if( 0 > gcIdx ) {
+ chosenGC = configs[gcIdx];
+ if(DEBUG) {
+ System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: Found matching AWT PFD ID "+winConfig.getPixelFormatID()+" -> "+winConfig);
+ }
+ }
+ }
+ } else {
+ chosenGC = device.getDefaultConfiguration();
}
-
+
if ( null == chosenGC ) {
throw new GLException("Unable to determine GraphicsConfiguration: "+winConfig);
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
index 7d03bbb88..7cc2d0f2e 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/GLXUtil.java
@@ -33,12 +33,12 @@
package jogamp.opengl.x11.glx;
-import javax.media.nativewindow.x11.X11GraphicsDevice;
import javax.media.opengl.GLException;
import jogamp.opengl.Debug;
import com.jogamp.common.util.VersionNumber;
+import com.jogamp.nativewindow.x11.X11GraphicsDevice;
public class GLXUtil {
public static final boolean DEBUG = Debug.debug("GLXUtil");
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java
index 6be74c0e9..a1039e552 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java
@@ -30,7 +30,10 @@ package jogamp.opengl.x11.glx;
import javax.media.opengl.*;
-import javax.media.nativewindow.x11.*;
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.x11.X11GraphicsDevice;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
+
import jogamp.nativewindow.*;
import jogamp.nativewindow.x11.*;
@@ -55,7 +58,7 @@ public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable {
X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice();
long dpy = device.getHandle();
int scrn = screen.getIndex();
- long visualID = config.getVisualID();
+ int visualID = config.getXVisualID();
dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID, f_dim, f_dim);
ns.setSurfaceHandle( dummyWindow );
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
index 6334799c0..700b25662 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java
@@ -40,11 +40,18 @@
package jogamp.opengl.x11.glx;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import javax.media.opengl.*;
-import jogamp.opengl.*;
-import jogamp.nativewindow.WrappedSurface;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLCapabilities;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+import jogamp.opengl.GLContextImpl;
+import jogamp.opengl.GLContextShareSet;
+
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
public class X11ExternalGLXContext extends X11GLXContext {
private GLContext lastContext;
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java
index ca30fde3b..4d0276163 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java
@@ -39,10 +39,15 @@
package jogamp.opengl.x11.glx;
-import javax.media.nativewindow.*;
-import javax.media.nativewindow.x11.*;
-import javax.media.opengl.*;
-import jogamp.nativewindow.WrappedSurface;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLDrawableFactory;
+import javax.media.opengl.GLException;
+import javax.media.opengl.GLProfile;
+
+
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
public class X11ExternalGLXDrawable extends X11GLXDrawable {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
index f4f01195f..bb0673581 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
@@ -29,43 +29,17 @@
package jogamp.opengl.x11.glx;
import jogamp.nativewindow.x11.XVisualInfo;
+
+import javax.media.nativewindow.NativeWindowException;
+import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-import java.util.Comparator;
public class X11GLCapabilities extends GLCapabilities {
- final XVisualInfo xVisualInfo; // maybe null if !onscreen
- final long fbcfg;
- final int fbcfgid;
-
- /** Comparing xvisual id only */
- public static class XVisualIDComparator implements Comparator {
-
- public int compare(Object o1, Object o2) {
- if ( ! ( o1 instanceof X11GLCapabilities ) ) {
- Class<?> c = (null != o1) ? o1.getClass() : null ;
- throw new ClassCastException("arg1 not a X11GLCapabilities object: " + c);
- }
- if ( ! ( o2 instanceof X11GLCapabilities ) ) {
- Class<?> c = (null != o2) ? o2.getClass() : null ;
- throw new ClassCastException("arg2 not a X11GLCapabilities object: " + c);
- }
-
- final X11GLCapabilities caps1 = (X11GLCapabilities) o1;
- final long id1 = caps1.getXVisualID();
-
- final X11GLCapabilities caps2 = (X11GLCapabilities) o2;
- final long id2 = caps2.getXVisualID();
-
- if(id1 > id2) {
- return 1;
- } else if(id1 < id2) {
- return -1;
- }
- return 0;
- }
- }
+ final private XVisualInfo xVisualInfo; // maybe null if !onscreen
+ final private long fbcfg;
+ final private int fbcfgid;
public X11GLCapabilities(XVisualInfo xVisualInfo, long fbcfg, int fbcfgid, GLProfile glp) {
super(glp);
@@ -78,7 +52,7 @@ public class X11GLCapabilities extends GLCapabilities {
super(glp);
this.xVisualInfo = xVisualInfo;
this.fbcfg = 0;
- this.fbcfgid = -1;
+ this.fbcfgid = VisualIDHolder.VID_UNDEFINED;
}
public Object cloneMutable() {
@@ -94,25 +68,38 @@ public class X11GLCapabilities extends GLCapabilities {
}
final public XVisualInfo getXVisualInfo() { return xVisualInfo; }
- final public long getXVisualID() { return (null!=xVisualInfo) ? xVisualInfo.getVisualid() : 0; }
+ final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : 0; }
final public boolean hasXVisualInfo() { return null!=xVisualInfo; }
final public long getFBConfig() { return fbcfg; }
final public int getFBConfigID() { return fbcfgid; }
- final public boolean hasFBConfig() { return 0!=fbcfg && fbcfgid>0; }
-
- final static String na_str = "----" ;
-
+ final public boolean hasFBConfig() { return 0!=fbcfg && fbcfgid!=VisualIDHolder.VID_UNDEFINED; }
+
+ @Override
+ final public int getVisualID(VIDType type) throws NativeWindowException {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ case X11_XVISUAL:
+ return getXVisualID();
+ case X11_FBCONFIG:
+ return getFBConfigID();
+ default:
+ throw new NativeWindowException("Invalid type <"+type+">");
+ }
+ }
+
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
+ sink.append("glx vid ");
if(hasXVisualInfo()) {
sink.append("0x").append(Long.toHexString(xVisualInfo.getVisualid()));
} else {
sink.append(na_str);
}
- sink.append(" ");
+ sink.append(", fbc ");
if(hasFBConfig()) {
sink.append("0x").append(Integer.toHexString(fbcfgid));
} else {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
index 55d0e9400..223c504e4 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java
@@ -49,8 +49,6 @@ import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.x11.X11GraphicsDevice;
-import javax.media.nativewindow.x11.X11GraphicsScreen;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLContext;
@@ -59,7 +57,6 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import javax.media.opengl.GLProfile.ShutdownType;
-import jogamp.nativewindow.WrappedSurface;
import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.X11Util;
import jogamp.opengl.DesktopGLDynamicLookupHelper;
@@ -70,6 +67,9 @@ import jogamp.opengl.GLDynamicLookupHelper;
import jogamp.opengl.SharedResourceRunner;
import com.jogamp.common.util.VersionNumber;
+import com.jogamp.nativewindow.WrappedSurface;
+import com.jogamp.nativewindow.x11.X11GraphicsDevice;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
index b2d679438..0af62394c 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -36,8 +36,6 @@ package jogamp.opengl.x11.glx;
import java.util.ArrayList;
import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.x11.X11GraphicsConfiguration;
-import javax.media.nativewindow.x11.X11GraphicsScreen;
import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GL;
import javax.media.opengl.GLCapabilities;
@@ -51,14 +49,13 @@ import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.XRenderDirectFormat;
import jogamp.nativewindow.x11.XRenderPictFormat;
import jogamp.nativewindow.x11.XVisualInfo;
-import jogamp.opengl.Debug;
import jogamp.opengl.GLGraphicsConfigurationUtil;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.nativewindow.x11.X11GraphicsConfiguration;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable {
- protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
-
public static final int MAX_ATTRIBS = 128;
private GLCapabilitiesChooser chooser;
@@ -176,14 +173,16 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
res[idx++] = caps.getGreenBits();
res[idx++] = GLX.GLX_BLUE_SIZE;
res[idx++] = caps.getBlueBits();
- res[idx++] = GLX.GLX_ALPHA_SIZE;
- res[idx++] = caps.getAlphaBits();
- res[idx++] = GLX.GLX_DEPTH_SIZE;
- res[idx++] = caps.getDepthBits();
+ if(caps.getAlphaBits()>0) {
+ res[idx++] = GLX.GLX_ALPHA_SIZE;
+ res[idx++] = caps.getAlphaBits();
+ }
if (caps.getStencilBits() > 0) {
res[idx++] = GLX.GLX_STENCIL_SIZE;
res[idx++] = caps.getStencilBits();
}
+ res[idx++] = GLX.GLX_DEPTH_SIZE;
+ res[idx++] = caps.getDepthBits();
if (caps.getAccumRedBits() > 0 ||
caps.getAccumGreenBits() > 0 ||
caps.getAccumBlueBits() > 0 ||
@@ -475,7 +474,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem
}
public String toString() {
- return "X11GLXGraphicsConfiguration["+getScreen()+", visualID " + toHexString(getVisualID()) + ", fbConfigID " + toHexString(getFBConfigID()) +
+ return "X11GLXGraphicsConfiguration["+getScreen()+", visualID " + toHexString(getXVisualID()) + ", fbConfigID " + toHexString(getFBConfigID()) +
",\n\trequested " + getRequestedCapabilities()+
",\n\tchosen " + getChosenCapabilities()+
"]";
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 5122ac5bb..22347ea5c 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -39,8 +39,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.x11.X11GraphicsScreen;
-import javax.media.nativewindow.x11.X11GraphicsDevice;
+import javax.media.nativewindow.VisualIDHolder;
import javax.media.opengl.DefaultGLCapabilitiesChooser;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesChooser;
@@ -50,6 +49,9 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import com.jogamp.common.nio.PointerBuffer;
+import com.jogamp.nativewindow.x11.X11GraphicsDevice;
+import com.jogamp.nativewindow.x11.X11GraphicsScreen;
+
import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.XVisualInfo;
import jogamp.opengl.GLGraphicsConfigurationFactory;
@@ -66,11 +68,12 @@ import java.util.List;
GraphicsDevice and GraphicsConfiguration abstractions. */
public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
- static X11GLCapabilities.XVisualIDComparator XVisualIDComparator = new X11GLCapabilities.XVisualIDComparator();
+ static VisualIDHolder.VIDComparator XVisualIDComparator = new VisualIDHolder.VIDComparator(VisualIDHolder.VIDType.X11_XVISUAL);
+
static GraphicsConfigurationFactory fallbackX11GraphicsConfigurationFactory = null;
static void registerFactory() {
final GraphicsConfigurationFactory newFactory = new X11GLXGraphicsConfigurationFactory();
- final GraphicsConfigurationFactory oldFactory = GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.x11.X11GraphicsDevice.class, newFactory);
+ final GraphicsConfigurationFactory oldFactory = GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.x11.X11GraphicsDevice.class, newFactory);
if(oldFactory == newFactory) {
throw new InternalError("GraphicsConfigurationFactory lifecycle impl. error");
}
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
index fc7aac06d..b2a8326cb 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java
@@ -75,7 +75,7 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
@Override
- protected void updateHandle() {
+ protected final void updateHandle() {
if(USE_GLXWINDOW) {
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration();
if(config.getFBConfig()>=0) {