summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r--src/jogl/classes/jogamp/opengl/GLDrawableImpl.java7
-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.java70
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java24
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java18
-rw-r--r--src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java204
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java17
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java21
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java3
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java102
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java26
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java13
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java2
14 files changed, 369 insertions, 203 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
index ba64127d4..36f17e5a1 100644
--- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
+++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java
@@ -135,12 +135,7 @@ public abstract class GLDrawableImpl implements GLDrawable {
protected void destroyHandle() {}
/** called with locked surface @ setRealized(true) or @ lockSurface(..) when surface changed */
- protected void updateHandle() {
- if(DEBUG) {
- System.err.println(getThreadName() + ": updateHandle: "+getClass().getSimpleName()+": "+this);
- Thread.dumpStack();
- }
- }
+ protected void updateHandle() {}
public long getHandle() {
return surface.getSurfaceHandle();
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..32055c5e0 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java
@@ -36,6 +36,8 @@
package jogamp.opengl.egl;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.opengl.GLDynamicLookupHelper;
import jogamp.opengl.GLDrawableImpl;
@@ -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,44 @@ 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);
+ eglDisplay = EGLDisplayUtil.eglGetDisplay(surface, true);
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);
- }
- 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 {
+ final int nativeVisualID;
+ {
+ final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) aConfig.getChosenCapabilities();
+ if(capsChosen instanceof NativeVisualID) {
+ nativeVisualID = ((NativeVisualID)capsChosen).getVisualID(NVIDType.NATIVE_ID);
+ } else {
+ nativeVisualID = -1;
+ }
+ }
+ eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
+ capsRequested, capsRequested, null, s, nativeVisualID);
+
+ 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 +214,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/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
index bd5eb1b99..cc7d267b0 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java
@@ -33,7 +33,9 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-public class EGLGLCapabilities extends GLCapabilities {
+import jogamp.nativewindow.NativeVisualID;
+
+public class EGLGLCapabilities extends GLCapabilities implements NativeVisualID {
final long eglcfg;
final int eglcfgid;
final int renderableType;
@@ -74,6 +76,7 @@ public class EGLGLCapabilities extends GLCapabilities {
" with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]");
}
this.renderableType = renderableType;
+ this.nativeVisualID = -1;
}
public Object cloneMutable() {
@@ -94,6 +97,21 @@ public class EGLGLCapabilities extends GLCapabilities {
final public void setNativeVisualID(int vid) { nativeVisualID=vid; }
final public int getNativeVisualID() { return nativeVisualID; }
+ final public int getVisualID(NVIDType type) {
+ switch(type) {
+ case GEN_ID:
+ // fall through intended
+ case EGL_ConfigID:
+ return getEGLConfigID();
+ case NATIVE_ID:
+ // fall through intended
+ case EGL_NativeVisualID:
+ return getNativeVisualID();
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
public static boolean isCompatible(GLProfile glp, int renderableType) {
if(null == glp) {
return true;
@@ -147,8 +165,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..99e8d1338 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java
@@ -50,15 +50,13 @@ 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;
public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable {
- protected static final boolean DEBUG = Debug.debug("GraphicsConfiguration");
-
+
public final long getNativeConfig() {
return ((EGLGLCapabilities)capabilitiesChosen).getEGLConfig();
}
@@ -275,11 +273,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..831dceac2 100644
--- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java
@@ -40,6 +40,7 @@ import javax.media.nativewindow.CapabilitiesChooser;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.DefaultGraphicsScreen;
import javax.media.nativewindow.GraphicsConfigurationFactory;
+import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.egl.EGLGraphicsDevice;
import javax.media.opengl.GLCapabilities;
@@ -52,8 +53,11 @@ import javax.media.opengl.GLDrawableFactory;
import com.jogamp.common.nio.Buffers;
import com.jogamp.common.nio.PointerBuffer;
+import jogamp.nativewindow.NativeVisualID;
+import jogamp.nativewindow.NativeVisualID.NVIDType;
import jogamp.opengl.GLGraphicsConfigurationFactory;
import jogamp.opengl.GLGraphicsConfigurationUtil;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -68,11 +72,24 @@ import java.nio.IntBuffer;
public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
static EGLGLCapabilities.EglCfgIDComparator EglCfgIDComparator = new EGLGLCapabilities.EglCfgIDComparator();
-
+ 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(javax.media.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(javax.media.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, -1);
+ } 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, -1);
+ if(null == cfg || 0>=((NativeVisualID)cfg.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID)) {
+ 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));
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index adfddddcd..6487dae1c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -30,6 +30,7 @@ package jogamp.opengl.windows.wgl;
import java.util.Comparator;
+import jogamp.nativewindow.NativeVisualID;
import jogamp.nativewindow.windows.GDI;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
import javax.media.opengl.GL;
@@ -37,7 +38,7 @@ import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
-public class WGLGLCapabilities extends GLCapabilities {
+public class WGLGLCapabilities extends GLCapabilities implements NativeVisualID {
final PIXELFORMATDESCRIPTOR pfd;
final int pfdID;
int arb_pixelformat; // -1 PFD, 0 NOP, 1 ARB
@@ -224,11 +225,23 @@ public class WGLGLCapabilities extends GLCapabilities {
final public boolean isSetByGDI() { return 0 > arb_pixelformat; }
final public boolean isSet() { return 0 != arb_pixelformat; }
+ final public int getVisualID(NVIDType type) {
+ switch(type) {
+ case GEN_ID:
+ case NATIVE_ID:
+ // fall through intended
+ case WIN32_PFDID:
+ return getPFDID();
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append(pfdID).append(" ");
+ sink.append("win32 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/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index cdb930280..3477a42c8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -54,10 +54,7 @@ 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 +453,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..a7042b347 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -230,6 +230,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..6c214a0f2 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/awt/WindowsAWTWGLGraphicsConfigurationFactory.java
@@ -56,6 +56,7 @@ 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;
@@ -104,8 +105,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 +113,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/X11GLCapabilities.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
index f4f01195f..9ca9c5e81 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
@@ -28,13 +28,14 @@
package jogamp.opengl.x11.glx;
+import jogamp.nativewindow.NativeVisualID;
import jogamp.nativewindow.x11.XVisualInfo;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import java.util.Comparator;
-public class X11GLCapabilities extends GLCapabilities {
+public class X11GLCapabilities extends GLCapabilities implements NativeVisualID {
final XVisualInfo xVisualInfo; // maybe null if !onscreen
final long fbcfg;
final int fbcfgid;
@@ -53,10 +54,10 @@ public class X11GLCapabilities extends GLCapabilities {
}
final X11GLCapabilities caps1 = (X11GLCapabilities) o1;
- final long id1 = caps1.getXVisualID();
+ final int id1 = caps1.getXVisualID();
final X11GLCapabilities caps2 = (X11GLCapabilities) o2;
- final long id2 = caps2.getXVisualID();
+ final int id2 = caps2.getXVisualID();
if(id1 > id2) {
return 1;
@@ -94,25 +95,40 @@ 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 public int getVisualID(NVIDType type) {
+ switch(type) {
+ case GEN_ID:
+ case NATIVE_ID:
+ // fall through intended
+ case X11_XVisualID:
+ return getXVisualID();
+ case X11_FBConfigID:
+ return getFBConfigID();
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
final static String na_str = "----" ;
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
+ sink.append("x11 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/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
index b2d679438..f1d804b35 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java
@@ -51,14 +51,11 @@ 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;
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 ||
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) {