From 3fbcf164be214f3c36bfc062e3ef63ddcc2e1687 Mon Sep 17 00:00:00 2001
From: Sven Gothel
* The default implementation is a NOP
, just setting the handle to null
.
*
+ * The specific implementing, ie {@link com.jogamp.nativewindow.x11.X11GraphicsDevice},
+ * shall have a enable/disable like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean)},
* which shall be invoked at creation time to determine ownership/role of freeing the resource.
*
* @return true if the handle was not null
, otherwise false.
diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
index 89cd3d60f..7a58e688f 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java
@@ -40,6 +40,8 @@
package javax.media.nativewindow;
+import javax.media.nativewindow.VisualIDHolder.VIDType;
+
/** Specifies a set of capabilities that a window's rendering context
must support, such as color depth per channel. It currently
contains the minimal number of routines which allow configuration
@@ -140,6 +142,17 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable, Comparabl
return 0; // they are equal: RGBA
}
+ @Override
+ public int getVisualID(VIDType type) throws NativeWindowException {
+ switch(type) {
+ case INTRINSIC:
+ case NATIVE:
+ return VisualIDHolder.VID_UNDEFINED;
+ default:
+ throw new NativeWindowException("Invalid type <"+type+">");
+ }
+ }
+
/** Returns the number of bits requested for the color buffer's red
component. On some systems only the color depth, which is the
sum of the red, green, and blue bits, is considered. */
@@ -331,4 +344,5 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable, Comparabl
msg.append("]");
return msg.toString();
}
+
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
index eccdf7797..848ec74e1 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java
@@ -36,7 +36,7 @@ import com.jogamp.common.type.WriteCloneable;
*
* @see javax.media.nativewindow.Capabilities
*/
-public interface CapabilitiesImmutable extends WriteCloneable {
+public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable {
/**
* Returns the number of bits requested for the color buffer's red
diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
index 15c9e6a36..a33c3792a 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java
@@ -44,13 +44,16 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
public DefaultGraphicsConfiguration(AbstractGraphicsScreen screen,
CapabilitiesImmutable capsChosen, CapabilitiesImmutable capsRequested) {
if(null == screen) {
- throw new NativeWindowException("Null screen");
+ throw new IllegalArgumentException("Null screen");
}
if(null == capsChosen) {
- throw new NativeWindowException("Null chosen caps");
+ throw new IllegalArgumentException("Null chosen caps");
}
if(null == capsRequested) {
- throw new NativeWindowException("Null requested caps");
+ throw new IllegalArgumentException("Null requested caps");
+ }
+ if( ! ( capsChosen instanceof VisualIDHolder ) ) {
+ throw new IllegalArgumentException("Chosen caps is not implementing NativeVisualID");
}
this.screen = screen;
this.capabilitiesChosen = capsChosen;
@@ -66,15 +69,15 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
}
}
- public AbstractGraphicsScreen getScreen() {
+ final public AbstractGraphicsScreen getScreen() {
return screen;
}
- public CapabilitiesImmutable getChosenCapabilities() {
+ final public CapabilitiesImmutable getChosenCapabilities() {
return capabilitiesChosen;
}
- public CapabilitiesImmutable getRequestedCapabilities() {
+ final public CapabilitiesImmutable getRequestedCapabilities() {
return capabilitiesRequested;
}
@@ -82,6 +85,11 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
return this;
}
+ @Override
+ final public int getVisualID(VIDType type) throws NativeWindowException {
+ return capabilitiesChosen.getVisualID(type);
+ }
+
/**
* Set the capabilities to a new value.
*
@@ -102,7 +110,7 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics
*
* A copy of the passed object is being used.
*/
- protected void setScreen(DefaultGraphicsScreen screen) {
+ final protected void setScreen(DefaultGraphicsScreen screen) {
this.screen = (AbstractGraphicsScreen) screen.clone();
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
index fb8bf2764..e5f230b4c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/GraphicsConfigurationFactory.java
@@ -223,12 +223,12 @@ public abstract class GraphicsConfigurationFactory {
* returned graphics configuration must be specified in the
* documentation binding this particular API to the underlying
* window toolkit. The Reference Implementation accepts {@link
- * javax.media.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
- * javax.media.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
+ * com.jogamp.nativewindow.awt.AWTGraphicsDevice AWTGraphicsDevice} objects and returns {@link
+ * com.jogamp.nativewindow.awt.AWTGraphicsConfiguration AWTGraphicsConfiguration} objects. On
* X11 platforms where the AWT is not in use, it also accepts
- * {@link javax.media.nativewindow.x11.X11GraphicsDevice
+ * {@link com.jogamp.nativewindow.x11.X11GraphicsDevice
* X11GraphicsDevice} objects and returns {@link
- * javax.media.nativewindow.x11.X11GraphicsConfiguration
+ * com.jogamp.nativewindow.x11.X11GraphicsConfiguration
* X11GraphicsConfiguration} objects.
+ * Allows queries of different types of native visual IDs, * see {@link #getVisualID(int)}. + *
*/ -public interface NativeVisualID { +public interface VisualIDHolder { - public enum NVIDType { - GEN_ID(0), NATIVE_ID(1), - EGL_ConfigID(2), EGL_NativeVisualID(3), X11_XVisualID(4), X11_FBConfigID(5), WIN32_PFDID(6); + public enum VIDType { + // Generic Values + INTRINSIC(0), NATIVE(1), + // EGL Values + EGL_CONFIG(10), + // X11 Values + X11_XVISUAL(20), X11_FBCONFIG(21), + // Windows Values + WIN32_PFD(30); public final int id; - NVIDType(int id){ + VIDType(int id){ this.id = id; } } /** - * Returns the native identification of the giventype
.
+ * Returns the native visual ID of the given type
+ * if supported, or {@link #VID_UNDEFINED} if not supported.
*
- * Depending on the native windowing system, this might be
+ * Depending on the native windowing system, type
is handled as follows:
*
EGL_CONFIG
, WIN32_PFD
* INTRINSIC
: X11 XVisual IDNATIVE
: X11 XVisual IDX11_XVISUAL
: X11 XVisual IDX11_FBCONFIG
: VID_UNDEFINED
EGL_CONFIG
, WIN32_PFD
* INTRINSIC
: X11 XVisual IDNATIVE
: X11 XVisual IDX11_XVISUAL
: X11 XVisual IDX11_FBCONFIG
: X11 FBConfig ID or VID_UNDEFINED
EGL_CONFIG
, X11_XVISUAL
, X11_FBCONFIG
* INTRINSIC
: Win32 PIXELFORMATDESCRIPTOR IDNATIVE
: Win32 PIXELFORMATDESCRIPTOR IDWIN32_PFD
: Win32 PIXELFORMATDESCRIPTOR IDX11_XVISUAL
, X11_FBCONFIG
, WIN32_PFD
* INTRINSIC
: EGL Config IDNATIVE
: EGL NativeVisual ID (X11 XVisual ID, Win32 PIXELFORMATDESCRIPTOR ID, ...)EGL_CONFIG
: EGL Config IDINTRINSIC
and NATIVE
are always handled,
+ * but may result in {@link #VID_UNDEFINED}. The latter is true if
+ * the native value are actually undefined or the corresponding object is not
+ * mapped to a native visual object.
+ *
+ * @throws NativeWindowException if type
is neither
+ * INTRINSIC
nor NATIVE
+ * and does not match the native implementation.
+ */
+ int getVisualID(VIDType type) throws NativeWindowException ;
+
+ /**
+ * {@link #getVisualID(VIDType)} result indicating an undefined value,
+ * which could be cause by an unsupported query.
+ *
+ * We assume the const value 0
doesn't reflect a valid native visual ID
+ * and is interpreted as no value on all platforms.
+ * This is currently true for Android, X11 and Windows.
+ *