diff options
author | Chien Yang <[email protected]> | 2004-10-01 01:04:36 +0000 |
---|---|---|
committer | Chien Yang <[email protected]> | 2004-10-01 01:04:36 +0000 |
commit | eced19d79a943c18f54dc7cbe693243e5953e792 (patch) | |
tree | 0d98627cc82661e26d4b94a1fce24c46f27261b9 /src/classes/linux/javax/media | |
parent | 7a5f73109c44b123dd6e785163f2a2aa2d53730a (diff) |
With this fix Java 3D will require GLX 1.3 or higher to
compile or run.
1) Fixed issue 20 - Off-screen rendering doesn't work on Linux.
2) Cleanup native chooseOglVisual code.
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@50 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/classes/linux/javax/media')
3 files changed, 57 insertions, 28 deletions
diff --git a/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java b/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java index 9a4bb27..edf86c7 100644 --- a/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java +++ b/src/classes/linux/javax/media/j3d/J3dGraphicsConfig.java @@ -36,8 +36,10 @@ class J3dGraphicsConfig { } static boolean isValidConfig(GraphicsConfiguration gc) { - // Check to see if a valid visInfo pointer has been cached. - Object visInfoObject = Canvas3D.visInfoTable.get(gc); - return (visInfoObject != null) && (visInfoObject instanceof Long); + // Check to see if a valid FBConfig pointer has been cached. + Object fbConfigObject = Canvas3D.fbConfigTable.get(gc); + return ((fbConfigObject != null) && + (fbConfigObject instanceof Long)); + } } diff --git a/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java b/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java index e5b18f7..1a7869b 100644 --- a/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java +++ b/src/classes/linux/javax/media/j3d/NativeConfigTemplate3D.java @@ -47,14 +47,14 @@ class NativeConfigTemplate3D { final static int NUM_ITEMS = 9; // Native method to get an OpenGL visual id and a pointer to the - // XVisualInfo struct itself. + // GLXFBConfig structure list itself. native int chooseOglVisual(long display, int screen, - int[] attrList, long[] visInfo); + int[] attrList, long[] fbConfig); - // Native method to free an XVisualInfo struct. This is static since it - // may need to be called to clean up the Canvas3D visInfoTable after the + // Native method to free an GLXFBConfig struct. This is static since it + // may need to be called to clean up the Canvas3D fbConfigTable after the // NativeConfigTemplate3D has been disposed of. - static native void freeVisual(long visInfo); + static native void freeFbConfig(long fbConfig); // Native methods to return whether a particular attribute is available native boolean isStereoAvailable(long display, int screen, int vid); @@ -64,7 +64,7 @@ class NativeConfigTemplate3D { /* - * Chooses the best visual for Java 3D apps. + * Chooses the best FBConfig for Java 3D apps. */ GraphicsConfiguration getBestConfiguration(GraphicsConfigTemplate3D template, @@ -73,8 +73,12 @@ class NativeConfigTemplate3D { X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc[0]).getDevice(); - NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); + if (!NativeScreenInfo.isGLX13()) { + return null; + } + NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); + long display = nativeScreenInfo.getDisplay(); int screen = nativeScreenInfo.getScreen(); @@ -92,7 +96,7 @@ class NativeConfigTemplate3D { if ((bounds.x != 0 || bounds.y != 0) && (! VirtualUniverse.mc.xineramaDisabled)) { // Xinerama is being used. The screen needs to be set to 0 since - // glxChooseVisual will not return a valid visual otherwise. + // glxChooseFBConfig will not return a valid visual otherwise. screen = 0; if (debug) { System.out.println(" Non-primary Xinerama screen:"); @@ -102,7 +106,7 @@ class NativeConfigTemplate3D { } int[] attrList; // holds the list of attributes to be translated - // for glxChooseVisual call + // for glxChooseFBConfig call attrList = new int[NUM_ITEMS]; @@ -116,15 +120,15 @@ class NativeConfigTemplate3D { attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); - long[] visInfo = new long[1]; - int visID = chooseOglVisual(display, screen, attrList, visInfo); + long[] fbConfig = new long[1]; + int visID = chooseOglVisual(display, screen, attrList, fbConfig); if (debug) { System.out.println(" chooseOglVisual() returns " + visID); - System.out.println(" pointer to XVisualInfo is " + visInfo[0]); + System.out.println(" pointer to GLXFBConfig is " + fbConfig[0]); System.out.println(); } - if (visID == 0 || visInfo[0] == 0) { + if (visID == 0 || fbConfig[0] == 0) { return null; // no valid visual was found } @@ -139,14 +143,14 @@ class NativeConfigTemplate3D { // TODO: This may or may not be needed for Linux // To support disabling Solaris OpenGL Xinerama mode, we need to cache - // the pointer to the actual XVisualInfo that glXChooseVisual() + // the pointer to the actual GLXFBConfig that glXChooseFBConfig() // returns, since this is not cached with X11GraphicsConfig and there - // are no public constructors to allow us to extend it. - synchronized (Canvas3D.visInfoTable) { - if (Canvas3D.visInfoTable.get(gc1) == null) - Canvas3D.visInfoTable.put(gc1, new Long(visInfo[0])); + // are no public constructors to allow us to extend it. + synchronized (Canvas3D.fbConfigTable) { + if (Canvas3D.fbConfigTable.get(gc1) == null) + Canvas3D.fbConfigTable.put(gc1, new Long(fbConfig[0])); else - freeVisual(visInfo[0]); + freeFbConfig(fbConfig[0]); } return gc1; @@ -162,6 +166,10 @@ class NativeConfigTemplate3D { X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); + if (!NativeScreenInfo.isGLX13()) { + return false; + } + NativeScreenInfo nativeScreenInfo = new NativeScreenInfo(gd); long display = nativeScreenInfo.getDisplay(); @@ -182,13 +190,13 @@ class NativeConfigTemplate3D { attrList[STEREO] = template.getStereo(); attrList[ANTIALIASING] = template.getSceneAntialiasing(); - long[] visInfo = new long[1]; - int visID = chooseOglVisual(display, screen, attrList, visInfo); + long[] fbConfig = new long[1]; + int visID = chooseOglVisual(display, screen, attrList, fbConfig); - if (visID == 0 || visInfo[0] == 0) - return false; // no valid visual was found + if (visID == 0 || fbConfig[0] == 0) + return false; // no valid visual was found else - return true; + return true; } @@ -232,7 +240,7 @@ class NativeConfigTemplate3D { } - // Return whether scene antialiasing is available. + // Return whether scene antialiasing is available. boolean hasSceneAntialiasingMultiSamples(GraphicsConfiguration gc) { X11GraphicsDevice gd = (X11GraphicsDevice)((X11GraphicsConfig)gc).getDevice(); diff --git a/src/classes/linux/javax/media/j3d/NativeScreenInfo.java b/src/classes/linux/javax/media/j3d/NativeScreenInfo.java index 2579f1f..aac8fa6 100644 --- a/src/classes/linux/javax/media/j3d/NativeScreenInfo.java +++ b/src/classes/linux/javax/media/j3d/NativeScreenInfo.java @@ -24,9 +24,28 @@ import sun.awt.X11GraphicsDevice; class NativeScreenInfo { private int screen; private static long display = 0; + private static boolean glxChecked = false; + private static boolean isGLX13; private native static long openDisplay(); private native static int getDefaultScreen(long display); + private native static boolean queryGLX13(long display); + + // Fix for issue 20. + // This method will return true if glx version is 1.3 or higher, + // else return false. + synchronized static boolean isGLX13() { + if (!glxChecked) { + // Open a new static display connection if one is not already opened. + getStaticDisplay(); + // Query for glx1.3 support. + isGLX13 = queryGLX13(display); + glxChecked = true; + } + + return isGLX13; + } + synchronized static long getStaticDisplay() { if (display == 0) { |