diff options
Diffstat (limited to 'gl4java/drawable/X11SunJDK13GLDrawableFactory.java')
-rw-r--r-- | gl4java/drawable/X11SunJDK13GLDrawableFactory.java | 80 |
1 files changed, 77 insertions, 3 deletions
diff --git a/gl4java/drawable/X11SunJDK13GLDrawableFactory.java b/gl4java/drawable/X11SunJDK13GLDrawableFactory.java index 0cdf40c..52ce5ec 100644 --- a/gl4java/drawable/X11SunJDK13GLDrawableFactory.java +++ b/gl4java/drawable/X11SunJDK13GLDrawableFactory.java @@ -1,5 +1,7 @@ package gl4java.drawable;
+import java.lang.reflect.*;
+import java.security.*;
import java.awt.*;
import sun.awt.*;
import gl4java.*;
@@ -7,6 +9,53 @@ import gl4java.*; public class X11SunJDK13GLDrawableFactory
extends SunJDK13GLDrawableFactory
{
+ private static Method getConfigMethod;
+
+ static {
+ try {
+ getConfigMethod = (Method)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run()
+ {
+ try {
+ return
+ sun.awt.X11GraphicsConfig.class.
+ getDeclaredMethod("getConfig",
+ new Class[]
+ { sun.awt.X11GraphicsDevice.class,
+ Integer.TYPE });
+ } catch (Exception e) {
+ if(GLContext.gljClassDebug)
+ {
+ System.out.println("GL4Java: MethodNotFound: sun.awt.X11GraphicsConfig::getConfig(Lsun/awt/X11GraphicsDevice;I) as seen in sun's std. jdk1.3 impl.");
+ System.out.println("GL4Java: trying sun.awt.X11GraphicsConfig::getConfig(Lsun/awt/X11GraphicsDevice;I;Z) as seen in sun's jdk1.4 beta impl.");
+ }
+ }
+
+ try {
+ return
+ sun.awt.X11GraphicsConfig.class.
+ getDeclaredMethod("getConfig",
+ new Class[]
+ { sun.awt.X11GraphicsDevice.class,
+ Integer.TYPE,
+ Boolean.TYPE });
+ } catch (Exception e) {
+ if(GLContext.gljClassDebug)
+ {
+ System.out.println("GL4Java: MethodNotFound: sun.awt.X11GraphicsConfig::getConfig(Lsun/awt/X11GraphicsDevice;I;Z) as seen in sun's std. jdk1.4 beta impl.");
+ }
+ e.printStackTrace();
+ throw new InternalError(e.toString());
+ }
+ }});
+
+ getConfigMethod.setAccessible(true);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new InternalError(e.toString());
+ }
+ }
public X11SunJDK13GLDrawableFactory() { }
@@ -19,6 +68,12 @@ public class X11SunJDK13GLDrawableFactory // in all of the parameters from the GLCapabilities,
X11GraphicsDevice x11Dev = (X11GraphicsDevice) device;
+ /**
+ * the X11GraphicsDevice::getDisplay() method is
+ * no more supported under jdk 1.4.
+ * also, the glXChooseVisualID native methods
+ * seeks the screen/display info direct by the XServer...
+
// From the code, this is ":0.<screen>".
// It looks like the X Display this is associated with is
// acquired via XOpenDisplay(NULL). It doesn't look like it's
@@ -29,17 +84,36 @@ public class X11SunJDK13GLDrawableFactory int visualID = (int) glXChooseVisualID (screen, display,
capabilities,
GLContext.gljNativeDebug);
+ */
+ int visualID = (int) glXChooseVisualID (capabilities,
+ GLContext.gljNativeDebug);
capabilities.setNativeVisualID( (long)visualID );
// Check for invalid return value (what will it be?)
// if (visualID invalid) return null;
- return X11GraphicsConfig.getConfig(x11Dev, visualID);
+ GraphicsConfiguration gcfg = null;
+
+ try {
+ if(getConfigMethod.getParameterTypes().length==2)
+ gcfg = (GraphicsConfiguration)
+ getConfigMethod.invoke(null,
+ new Object[] { x11Dev, new Integer(visualID)});
+ else
+ gcfg = (GraphicsConfiguration)
+ getConfigMethod.invoke(null,
+ new Object[] { x11Dev, new Integer(visualID),
+ new Boolean(capabilities.getDoubleBuffered())});
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new InternalError(e.toString());
+ }
+
+ return gcfg;
}
// Needs to return an XVisualID which can be wrapped in an
// X11GraphicsConfig object
- static native long glXChooseVisualID (int screen, long display,
- GLCapabilities capabilities,
+ static native long glXChooseVisualID (GLCapabilities capabilities,
boolean verbose);
}
|