summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-03-05 22:14:09 +0100
committerSven Gothel <[email protected]>2012-03-05 22:14:09 +0100
commitcb399dc16beeeddcd8215cd276bbaff25c6fc0ca (patch)
treee0e3df670188addf21bd486c079defb1886d0ec9
parent9ea78af201414e0eb5daa62ab8b72d7204590c40 (diff)
X11 Fix NativeVisualID regression (commit 90c46b1ef1f199ceb63e85c85e9ebeb919d49c4a) ; Using plain X11 Capabilities
In case X11GLXGraphicsConfigurationFactory and hence X11GLCapabilities (glx) is not being used, the X11GraphicsConfigurationFactory used plain Capabilities object for the chosen caps. The latter is not derived from NativeVisualID. - Added X11Capabilities supporting NativeVisualID to fit our needs. - X11Capabilities.XVisualIDComparator uses NativeVisualID.NVIDType.X11_XVisualID - *Capabilities have better unique names in toString()
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java33
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java4
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/Capabilities.java2
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java10
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java115
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java3
7 files changed, 132 insertions, 37 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
index 6487dae1c..5812b3153 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java
@@ -241,7 +241,7 @@ public class WGLGLCapabilities extends GLCapabilities implements NativeVisualID
if(null == sink) {
sink = new StringBuffer();
}
- sink.append("win32 vid 0x").append(Integer.toHexString(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/x11/glx/X11GLCapabilities.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
index 9ca9c5e81..008b0d6fc 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java
@@ -33,41 +33,12 @@ 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 implements NativeVisualID {
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 int id1 = caps1.getXVisualID();
-
- final X11GLCapabilities caps2 = (X11GLCapabilities) o2;
- final int id2 = caps2.getXVisualID();
-
- if(id1 > id2) {
- return 1;
- } else if(id1 < id2) {
- return -1;
- }
- return 0;
- }
- }
-
public X11GLCapabilities(XVisualInfo xVisualInfo, long fbcfg, int fbcfgid, GLProfile glp) {
super(glp);
this.xVisualInfo = xVisualInfo;
@@ -116,13 +87,11 @@ public class X11GLCapabilities extends GLCapabilities implements NativeVisualID
}
}
- final static String na_str = "----" ;
-
public StringBuffer toString(StringBuffer sink) {
if(null == sink) {
sink = new StringBuffer();
}
- sink.append("x11 vid ");
+ sink.append("glx vid ");
if(hasXVisualInfo()) {
sink.append("0x").append(Long.toHexString(xVisualInfo.getVisualid()));
} else {
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
index 5122ac5bb..b118f529f 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java
@@ -50,6 +50,8 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLProfile;
import com.jogamp.common.nio.PointerBuffer;
+
+import jogamp.nativewindow.x11.X11Capabilities;
import jogamp.nativewindow.x11.X11Lib;
import jogamp.nativewindow.x11.XVisualInfo;
import jogamp.opengl.GLGraphicsConfigurationFactory;
@@ -66,7 +68,7 @@ import java.util.List;
GraphicsDevice and GraphicsConfiguration abstractions. */
public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory {
- static X11GLCapabilities.XVisualIDComparator XVisualIDComparator = new X11GLCapabilities.XVisualIDComparator();
+ static X11Capabilities.XVisualIDComparator XVisualIDComparator = new X11Capabilities.XVisualIDComparator();
static GraphicsConfigurationFactory fallbackX11GraphicsConfigurationFactory = null;
static void registerFactory() {
final GraphicsConfigurationFactory newFactory = new X11GLXGraphicsConfigurationFactory();
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index 368847e5c..89cd3d60f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -45,6 +45,8 @@ package javax.media.nativewindow;
contains the minimal number of routines which allow configuration
on all supported window systems. */
public class Capabilities implements CapabilitiesImmutable, Cloneable, Comparable {
+ protected final static String na_str = "----" ;
+
private int redBits = 8;
private int greenBits = 8;
private int blueBits = 8;
diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
index 3451e28e8..20d3ad6dc 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/NativeVisualID.java
@@ -56,15 +56,21 @@ public interface NativeVisualID {
* <li>GEN_ID: X11_XVisualID</li>
* <li>NATIVE_ID: X11_XVisualID</li>
* <li>X11_XVisualID</li>
+ * </ul></li>
+ * <li>X11/GL
+ * <ul>
+ * <li>GEN_ID: X11_XVisualID</li>
+ * <li>NATIVE_ID: X11_XVisualID</li>
+ * <li>X11_XVisualID</li>
* <li>X11FBConfigID</li>
* </ul></li>
- * <li>Windows
+ * <li>Windows/GL
* <ul>
* <li>GEN_ID: WIN32_PFDID</li>
* <li>NATIVE_ID: WIN32_PFDID</li>
* <li>WIN32_PFDID</li>
* </ul></li>
- * <li>EGL
+ * <li>EGL/GL
* <ul>
* <li>GEN_ID: EGL_ConfigID</li>
* <li>NATIVE_ID: EGL_NativeVisualID (X11_XVisualID, WIN32_PFDID, ..)</li>
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java
new file mode 100644
index 000000000..2e9ab5485
--- /dev/null
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright 2012 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package jogamp.nativewindow.x11;
+
+import jogamp.nativewindow.NativeVisualID;
+import java.util.Comparator;
+
+import javax.media.nativewindow.Capabilities;
+import javax.media.nativewindow.NativeWindowException;
+
+public class X11Capabilities extends Capabilities implements NativeVisualID {
+ final XVisualInfo xVisualInfo; // maybe null if !onscreen
+
+ /** Comparing xvisual id only */
+ public static class XVisualIDComparator implements Comparator {
+ public int compare(Object o1, Object o2) {
+ if ( ! ( o1 instanceof NativeVisualID ) ) {
+ Class<?> c = (null != o1) ? o1.getClass() : null ;
+ throw new ClassCastException("arg1 not a NativeVisualID object: " + c);
+ }
+ if ( ! ( o2 instanceof NativeVisualID ) ) {
+ Class<?> c = (null != o2) ? o2.getClass() : null ;
+ throw new ClassCastException("arg2 not a NativeVisualID object: " + c);
+ }
+
+ final NativeVisualID nvid1 = (NativeVisualID) o1;
+ final int id1 = nvid1.getVisualID(NativeVisualID.NVIDType.X11_XVisualID);
+
+ final NativeVisualID nvid2 = (NativeVisualID) o2;
+ final int id2 = nvid2.getVisualID(NativeVisualID.NVIDType.X11_XVisualID);
+
+ if(id1 > id2) {
+ return 1;
+ } else if(id1 < id2) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+
+ public X11Capabilities(XVisualInfo xVisualInfo) {
+ super();
+ this.xVisualInfo = xVisualInfo;
+ }
+
+ public Object cloneMutable() {
+ return clone();
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (RuntimeException e) {
+ throw new NativeWindowException(e);
+ }
+ }
+
+ final public XVisualInfo getXVisualInfo() { return xVisualInfo; }
+ final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : 0; }
+ final public boolean hasXVisualInfo() { return null!=xVisualInfo; }
+
+ 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:
+ // fall through intended
+ default:
+ throw new IllegalArgumentException("Invalid type <"+type+">");
+ }
+ }
+
+ 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(": ");
+ return super.toString(sink);
+ }
+} \ No newline at end of file
diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java
index 490290654..6324389f4 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11GraphicsConfigurationFactory.java
@@ -56,7 +56,8 @@ public class X11GraphicsConfigurationFactory extends GraphicsConfigurationFactor
if(!(screen instanceof X11GraphicsScreen)) {
throw new NativeWindowException("Only valid X11GraphicsScreen are allowed");
}
- AbstractGraphicsConfiguration res = new X11GraphicsConfiguration((X11GraphicsScreen)screen, capsChosen, capsRequested, getXVisualInfo(screen, capsChosen));
+ final X11Capabilities x11CapsChosen = new X11Capabilities(getXVisualInfo(screen, capsChosen));
+ AbstractGraphicsConfiguration res = new X11GraphicsConfiguration((X11GraphicsScreen)screen, x11CapsChosen, capsRequested, x11CapsChosen.getXVisualInfo());
if(DEBUG) {
System.err.println("X11GraphicsConfigurationFactory.chooseGraphicsConfigurationImpl("+screen+","+capsChosen+"): "+res);
Thread.dumpStack();