summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/jogamp
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 /src/nativewindow/classes/jogamp
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()
Diffstat (limited to 'src/nativewindow/classes/jogamp')
-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
3 files changed, 125 insertions, 3 deletions
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();