diff options
author | Sven Gothel <[email protected]> | 2012-03-06 09:59:34 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-03-06 09:59:34 +0100 |
commit | 3fbcf164be214f3c36bfc062e3ef63ddcc2e1687 (patch) | |
tree | 7172ac49435fc1cce26c82809b93322d1e72df0e | |
parent | efa70cd39e1a2ac18c3e8660f8d57e4569b19018 (diff) |
NativeWindow public* reorg 3/3 ; NativeVisualID -> VisualIDHolder incl. proper utilization.
- VisualIDHolder: Update documentation (Exception case, etc)
- NativeVisualID -> VisualIDHolder (public)
- incl. generic Comparator
- better doc and enum values
- VID_UNDEFINED == 0
- methods shall not throw exception, but return UNDEFINED
- CapabilitiesImmutable extends VisualIDHolder
- All Capabilties impl.
- use VID_UNDEFINED for undef. value
- use final private (immutable) fields
- AbstractGraphicsConfiguration extends VisualIDHolder
- X11 CreateDummyWindow takes (int) visualID
20 files changed, 252 insertions, 250 deletions
diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 8ac557501..73439fcc7 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -26,7 +26,7 @@ public static native long DefaultVisualID(long display, int screen); - public static native long CreateDummyWindow(long display, int screen_index, long visualID, int width, int height); + public static native long CreateDummyWindow(long display, int screen_index, int visualID, int width, int height); public static native void DestroyDummyWindow(long display, long window); public static Point GetRelativeLocation(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index 32055c5e0..b54089d13 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -36,15 +36,15 @@ package jogamp.opengl.egl; -import jogamp.nativewindow.NativeVisualID; -import jogamp.nativewindow.NativeVisualID.NVIDType; 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 @@ -181,17 +181,8 @@ public abstract class EGLDrawable extends GLDrawableImpl { 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); + capsRequested, capsRequested, null, s, aConfig.getVisualID(VIDType.NATIVE)); if (null == eglConfig) { throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 53043c3cc..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; @@ -358,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 cc7d267b0..2e1793d72 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -28,46 +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; -import jogamp.nativewindow.NativeVisualID; -public class EGLGLCapabilities extends GLCapabilities implements NativeVisualID { - final long eglcfg; - final int eglcfgid; - final int renderableType; - int nativeVisualID; +public class EGLGLCapabilities extends GLCapabilities { + 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; @@ -76,7 +60,7 @@ public class EGLGLCapabilities extends GLCapabilities implements NativeVisualID " with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]"); } this.renderableType = renderableType; - this.nativeVisualID = -1; + this.nativeVisualID = visualID; } public Object cloneMutable() { @@ -94,21 +78,18 @@ public class EGLGLCapabilities extends GLCapabilities implements NativeVisualID 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; } - final public int getVisualID(NVIDType type) { + @Override + final public int getVisualID(VIDType type) throws NativeWindowException { switch(type) { - case GEN_ID: - // fall through intended - case EGL_ConfigID: + case INTRINSIC: + case EGL_CONFIG: return getEGLConfigID(); - case NATIVE_ID: - // fall through intended - case EGL_NativeVisualID: + case NATIVE: return getNativeVisualID(); default: - throw new IllegalArgumentException("Invalid type <"+type+">"); + throw new NativeWindowException("Invalid type <"+type+">"); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 70f62e3e6..35e30c5f4 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -42,6 +42,7 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; @@ -170,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)) { @@ -188,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); @@ -199,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)); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 831dceac2..2d9fc0227 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -40,8 +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.VisualIDHolder; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.egl.EGLGraphicsDevice; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -52,9 +53,8 @@ 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.nativewindow.NativeVisualID; -import jogamp.nativewindow.NativeVisualID.NVIDType; import jogamp.opengl.GLGraphicsConfigurationFactory; import jogamp.opengl.GLGraphicsConfigurationUtil; @@ -71,7 +71,7 @@ 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() { @@ -80,14 +80,14 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact // 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); + 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, eglFactory); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.egl.EGLGraphicsDevice.class, eglFactory); } private EGLGraphicsConfigurationFactory() { @@ -125,7 +125,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen, (GLCapabilitiesImmutable) capsRequested, (GLCapabilitiesChooser) chooser, - absScreen, -1); + absScreen, VisualIDHolder.VID_UNDEFINED); } else { // handle non native cases (X11, ..) if(null == nativeGraphicsConfigurationFactory) { @@ -139,8 +139,8 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact cfg = chooseGraphicsConfigurationStatic((GLCapabilitiesImmutable) capsChosen, (GLCapabilitiesImmutable) capsRequested, (GLCapabilitiesChooser) chooser, - absScreen, -1); - if(null == cfg || 0>=((NativeVisualID)cfg.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID)) { + 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 .."); @@ -321,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"); } @@ -370,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++; @@ -383,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()); } } @@ -431,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/windows/wgl/WGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java index 5812b3153..24bc5aea6 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WGLGLCapabilities.java @@ -28,48 +28,19 @@ 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.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 implements NativeVisualID { - 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; - } - } +public class WGLGLCapabilities extends GLCapabilities { + 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); @@ -225,15 +196,15 @@ public class WGLGLCapabilities extends GLCapabilities implements NativeVisualID final public boolean isSetByGDI() { return 0 > arb_pixelformat; } final public boolean isSet() { return 0 != arb_pixelformat; } - final public int getVisualID(NVIDType type) { + @Override + final public int getVisualID(VIDType type) throws NativeWindowException { switch(type) { - case GEN_ID: - case NATIVE_ID: - // fall through intended - case WIN32_PFDID: + case INTRINSIC: + case NATIVE: + case WIN32_PFD: return getPFDID(); default: - throw new IllegalArgumentException("Invalid type <"+type+">"); + throw new NativeWindowException("Invalid type <"+type+">"); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java index 008b0d6fc..bb0673581 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLCapabilities.java @@ -28,16 +28,18 @@ package jogamp.opengl.x11.glx; -import jogamp.nativewindow.NativeVisualID; 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; -public class X11GLCapabilities extends GLCapabilities implements NativeVisualID { - final XVisualInfo xVisualInfo; // maybe null if !onscreen - final long fbcfg; - final int fbcfgid; +public class X11GLCapabilities extends GLCapabilities { + 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); @@ -50,7 +52,7 @@ public class X11GLCapabilities extends GLCapabilities implements NativeVisualID super(glp); this.xVisualInfo = xVisualInfo; this.fbcfg = 0; - this.fbcfgid = -1; + this.fbcfgid = VisualIDHolder.VID_UNDEFINED; } public Object cloneMutable() { @@ -71,19 +73,19 @@ public class X11GLCapabilities extends GLCapabilities implements NativeVisualID final public long getFBConfig() { return fbcfg; } final public int getFBConfigID() { return fbcfgid; } - final public boolean hasFBConfig() { return 0!=fbcfg && fbcfgid>0; } + final public boolean hasFBConfig() { return 0!=fbcfg && fbcfgid!=VisualIDHolder.VID_UNDEFINED; } - final public int getVisualID(NVIDType type) { + @Override + final public int getVisualID(VIDType type) throws NativeWindowException { switch(type) { - case GEN_ID: - case NATIVE_ID: - // fall through intended - case X11_XVisualID: + case INTRINSIC: + case NATIVE: + case X11_XVISUAL: return getXVisualID(); - case X11_FBConfigID: + case X11_FBCONFIG: return getFBConfigID(); default: - throw new IllegalArgumentException("Invalid type <"+type+">"); + throw new NativeWindowException("Invalid type <"+type+">"); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index b118f529f..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,8 +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.X11Capabilities; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.XVisualInfo; import jogamp.opengl.GLGraphicsConfigurationFactory; @@ -68,11 +68,12 @@ import java.util.List; GraphicsDevice and GraphicsConfiguration abstractions. */ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationFactory { - static X11Capabilities.XVisualIDComparator XVisualIDComparator = new X11Capabilities.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/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java index 1930bdda3..ebdaf2fbb 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java @@ -43,7 +43,7 @@ package javax.media.nativewindow; /** A marker interface describing a graphics configuration, visual, or pixel format in a toolkit-independent manner. */ -public interface AbstractGraphicsConfiguration extends Cloneable { +public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable { /** * Return the screen this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index fa25c214f..1dd01a274 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -114,8 +114,8 @@ public interface AbstractGraphicsDevice extends Cloneable { * <p> * The default implementation is a <code>NOP</code>, just setting the handle to <code>null</code>. * </p> - * The specific implementing, ie {@link javax.media.nativewindow.x11.X11GraphicsDevice}, - * shall have a enable/disable like {@link javax.media.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean)},<br> + * 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)},<br> * which shall be invoked at creation time to determine ownership/role of freeing the resource.<br> * * @return true if the handle was not <code>null</code>, 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.</P> * * @param capsChosen the intermediate chosen capabilities to be refined by this implementation, may be equal to capsRequested diff --git a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java index 20d3ad6dc..4f3d3ff00 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java +++ b/src/nativewindow/classes/javax/media/nativewindow/VisualIDHolder.java @@ -26,59 +26,110 @@ * or implied, of JogAmp Community. */ -package jogamp.nativewindow; +package javax.media.nativewindow; + +import java.util.Comparator; /** - * Specifies query to the native capabilities identification. - * Semantics may differ depending on the native windowing system, + * Visual ID holder interface. + * <p> + * Allows queries of different types of native visual IDs, * see {@link #getVisualID(int)}. + * </p> */ -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 given <code>type</code>. + * Returns the native visual ID of the given <code>type</code> + * if supported, or {@link #VID_UNDEFINED} if not supported. * <p> - * Depending on the native windowing system, this might be + * Depending on the native windowing system, <code>type</code> is handled as follows: * <ul> - * <li>X11 + * <li>X11 throws NativeWindowException on <code>EGL_CONFIG</code>, <code>WIN32_PFD</code> * <ul> - * <li>GEN_ID: X11_XVisualID</li> - * <li>NATIVE_ID: X11_XVisualID</li> - * <li>X11_XVisualID</li> + * <li><code>INTRINSIC</code>: <i>X11 XVisual ID</i></li> + * <li><code>NATIVE</code>: <i>X11 XVisual ID</i></li> + * <li><code>X11_XVISUAL</code>: <i>X11 XVisual ID</i></li> + * <li><code>X11_FBCONFIG</code>: <code>VID_UNDEFINED</code></li> * </ul></li> - * <li>X11/GL + * <li>X11/GL throws NativeWindowException on <code>EGL_CONFIG</code>, <code>WIN32_PFD</code> * <ul> - * <li>GEN_ID: X11_XVisualID</li> - * <li>NATIVE_ID: X11_XVisualID</li> - * <li>X11_XVisualID</li> - * <li>X11FBConfigID</li> + * <li><code>INTRINSIC</code>: <i>X11 XVisual ID</i></li> + * <li><code>NATIVE</code>: <i>X11 XVisual ID</i></li> + * <li><code>X11_XVISUAL</code>: <i>X11 XVisual ID</i></li> + * <li><code>X11_FBCONFIG</code>: <i>X11 FBConfig ID</i> or <code>VID_UNDEFINED</code></li> * </ul></li> - * <li>Windows/GL + * <li>Windows/GL throws NativeWindowException on <code>EGL_CONFIG</code>, <code>X11_XVISUAL</code>, <code>X11_FBCONFIG</code> * <ul> - * <li>GEN_ID: WIN32_PFDID</li> - * <li>NATIVE_ID: WIN32_PFDID</li> - * <li>WIN32_PFDID</li> + * <li><code>INTRINSIC</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li> + * <li><code>NATIVE</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li> + * <li><code>WIN32_PFD</code>: <i>Win32 PIXELFORMATDESCRIPTOR ID</i></li> * </ul></li> - * <li>EGL/GL + * <li>EGL/GL throws NativeWindowException on <code>X11_XVISUAL</code>, <code>X11_FBCONFIG</code>, <code>WIN32_PFD</code> * <ul> - * <li>GEN_ID: EGL_ConfigID</li> - * <li>NATIVE_ID: EGL_NativeVisualID (X11_XVisualID, WIN32_PFDID, ..)</li> - * <li>EGL_ConfigID</li> - * <li>EGL_NativeVisualID</li> + * <li><code>INTRINSIC</code>: <i>EGL Config ID</i></li> + * <li><code>NATIVE</code>: <i>EGL NativeVisual ID</i> (<i>X11 XVisual ID</i>, <i>Win32 PIXELFORMATDESCRIPTOR ID</i>, ...)</li> + * <li><code>EGL_CONFIG</code>: <i>EGL Config ID</i></li> * </ul></li> * </ul> * </p> + * Note: <code>INTRINSIC</code> and <code>NATIVE</code> 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 <code>type</code> is neither + * <code>INTRINSIC</code> nor <code>NATIVE</code> + * 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. + * <p> + * We assume the const value <code>0</code> doesn't reflect a valid native visual ID + * and is interpreted as <i>no value</i> on all platforms. + * This is currently true for Android, X11 and Windows. + * </p> */ - int getVisualID(NVIDType type); + static final int VID_UNDEFINED = 0; + + /** Comparing {@link VIDType#NATIVE} */ + public static class VIDComparator implements Comparator<VisualIDHolder> { + private VIDType type; + + public VIDComparator(VIDType type) { + this.type = type; + } + + public int compare(VisualIDHolder vid1, VisualIDHolder vid2) { + final int id1 = vid1.getVisualID(type); + final int id2 = vid2.getVisualID(type); + + if(id1 > id2) { + return 1; + } else if(id1 < id2) { + return -1; + } + return 0; + } + } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java index 2e9ab5485..f9eee67f3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Capabilities.java @@ -28,41 +28,12 @@ package jogamp.nativewindow.x11; -import jogamp.nativewindow.NativeVisualID; -import java.util.Comparator; - import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; -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 class X11Capabilities extends Capabilities { + final private XVisualInfo xVisualInfo; // maybe null if !onscreen public X11Capabilities(XVisualInfo xVisualInfo) { super(); @@ -82,20 +53,21 @@ public class X11Capabilities extends Capabilities implements NativeVisualID { } final public XVisualInfo getXVisualInfo() { return xVisualInfo; } - final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : 0; } + final public int getXVisualID() { return (null!=xVisualInfo) ? (int) xVisualInfo.getVisualid() : VisualIDHolder.VID_UNDEFINED; } final public boolean hasXVisualInfo() { return null!=xVisualInfo; } - final public int getVisualID(NVIDType type) { + @Override + final public int getVisualID(VIDType type) throws NativeWindowException { switch(type) { - case GEN_ID: - case NATIVE_ID: + case INTRINSIC: + case NATIVE: // fall through intended - case X11_XVisualID: + case X11_XVISUAL: return getXVisualID(); - case X11_FBConfigID: - // fall through intended + case X11_FBCONFIG: + return VisualIDHolder.VID_UNDEFINED; default: - throw new IllegalArgumentException("Invalid type <"+type+">"); + throw new NativeWindowException("Invalid type <"+type+">"); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index 5dc143559..697be9f93 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -42,17 +42,18 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ToolkitLock; -import javax.media.nativewindow.awt.AWTGraphicsConfiguration; -import javax.media.nativewindow.awt.AWTGraphicsDevice; -import javax.media.nativewindow.awt.AWTGraphicsScreen; -import javax.media.nativewindow.x11.X11GraphicsDevice; -import javax.media.nativewindow.x11.X11GraphicsScreen; +import javax.media.nativewindow.VisualIDHolder.VIDType; + +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; -import jogamp.nativewindow.NativeVisualID; -import jogamp.nativewindow.NativeVisualID.NVIDType; import jogamp.nativewindow.jawt.x11.X11SunJDKReflection; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; @@ -60,7 +61,7 @@ import jogamp.nativewindow.x11.X11Util; public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFactory { public static void registerFactory() { - GraphicsConfigurationFactory.registerFactory(javax.media.nativewindow.awt.AWTGraphicsDevice.class, new X11AWTGraphicsConfigurationFactory()); + GraphicsConfigurationFactory.registerFactory(com.jogamp.nativewindow.awt.AWTGraphicsDevice.class, new X11AWTGraphicsConfigurationFactory()); } private X11AWTGraphicsConfigurationFactory() { } @@ -138,17 +139,19 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac // ie. returned by GLCanvas's getGraphicsConfiguration() befor call by super.addNotify(). // final GraphicsConfiguration[] configs = device.getConfigurations(); - int visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID); - for (int i = 0; i < configs.length; i++) { - GraphicsConfiguration gc = configs[i]; - if (gc != null) { - if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { - if(DEBUG) { - System.err.println("Found matching AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + int visualID = aConfig.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED != visualID) { + for (int i = 0; i < configs.length; i++) { + GraphicsConfiguration gc = configs[i]; + if (gc != null) { + if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { + if(DEBUG) { + System.err.println("Found matching AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + } + return new AWTGraphicsConfiguration(awtScreen, + aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), + gc, aConfig); } - return new AWTGraphicsConfiguration(awtScreen, - aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), - gc, aConfig); } } } @@ -160,16 +163,18 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac if (aConfig == null) { throw new NativeWindowException("Unable to choose a GraphicsConfiguration (2): "+capsChosen+",\n\t"+chooser+"\n\t"+x11Screen); } - visualID = ((NativeVisualID) aConfig.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID); - for (int i = 0; i < configs.length; i++) { - gc = configs[i]; - if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { - if(DEBUG) { - System.err.println("Found matching default AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + visualID = aConfig.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED != visualID) { + for (int i = 0; i < configs.length; i++) { + gc = configs[i]; + if (X11SunJDKReflection.graphicsConfigurationGetVisualID(gc) == visualID) { + if(DEBUG) { + System.err.println("Found matching default AWT visual: 0x"+Integer.toHexString(visualID) +" -> "+aConfig); + } + return new AWTGraphicsConfiguration(awtScreen, + aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), + gc, aConfig); } - return new AWTGraphicsConfiguration(awtScreen, - aConfig.getChosenCapabilities(), aConfig.getRequestedCapabilities(), - gc, aConfig); } } diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index a99499879..d2b24c2dc 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -420,10 +420,10 @@ Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused /* * Class: jogamp_nativewindow_x11_X11Lib * Method: CreateDummyWindow - * Signature: (JIJII)J + * Signature: (JIIII)J */ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow - (JNIEnv *env, jclass unused, jlong display, jint screen_index, jlong visualID, jint width, jint height) + (JNIEnv *env, jclass unused, jlong display, jint screen_index, jint visualID, jint width, jint height) { Display * dpy = (Display *)(intptr_t)display; int scrn_idx = (int)screen_index; @@ -463,7 +463,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow if(pVisualQuery!=NULL) { visual = pVisualQuery->visual; depth = pVisualQuery->depth; - visualID = (jlong)pVisualQuery->visualid; + visualID = (jint)pVisualQuery->visualid; XFree(pVisualQuery); pVisualQuery=NULL; } diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java index ad691eb0b..703b18272 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java @@ -34,13 +34,12 @@ package jogamp.newt.driver.x11; -import jogamp.nativewindow.NativeVisualID; -import jogamp.nativewindow.NativeVisualID.NVIDType; import jogamp.nativewindow.x11.X11Lib; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.WindowImpl; import javax.media.nativewindow.*; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -73,8 +72,11 @@ public class X11Window extends WindowImpl { if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } + final int visualID = cfg.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED == visualID) { + throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); + } setGraphicsConfiguration(cfg); - final int visualID = ((NativeVisualID) cfg.getChosenCapabilities()).getVisualID(NVIDType.NATIVE_ID); final int flags = getReconfigureFlags(0, true) & ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; setWindowHandle(CreateWindow0(getParentWindowHandle(), |