Login  Register

Re: Javafx causes jogl problem in mac

Posted by gouessej on Mar 13, 2013; 7:53pm
URL: https://forum.jogamp.org/Javafx-causes-jogl-problem-in-mac-tp4028417p4028619.html

I have done that on GLCanvas:
diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
index 63c18db..160c270 100644
--- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
+++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
@@ -1178,21 +1178,26 @@
     AWTGraphicsConfiguration config = null;
 
     if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) {
-        config = (AWTGraphicsConfiguration)
-                GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen,
-                                                                                                             capsRequested,
-                                                                                                             chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
+     AbstractGraphicsConfiguration a = GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen,
+                capsRequested,
+                chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
+     if (a instanceof AWTGraphicsConfiguration) {
+            config = (AWTGraphicsConfiguration) a;
+     }
+                
     } else {
         try {
             final ArrayList<AWTGraphicsConfiguration> bucket = new ArrayList<AWTGraphicsConfiguration>(1);
             EventQueue.invokeAndWait(new Runnable() {
                 @Override
                 public void run() {
-                    AWTGraphicsConfiguration c = (AWTGraphicsConfiguration)
-                            GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen,
-                                                                                                                         capsRequested,
-                                                                                                                         chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
-                    bucket.add(c);
+                 AbstractGraphicsConfiguration a = GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, GLCapabilitiesImmutable.class).chooseGraphicsConfiguration(capsChosen,
+                            capsRequested,
+                            chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
+                 if (a instanceof AWTGraphicsConfiguration) {
+                 AWTGraphicsConfiguration c = (AWTGraphicsConfiguration) a;
+                        bucket.add(c);
+                 }
                 }
             });
             config = ( bucket.size() > 0 ) ? bucket.get(0) : null ;



but the problem will still be there, you will just get an error message "Error: Couldn't fetch AWTGraphicsConfiguration" instead of the ClassCastException. The problem is that a DefaultGraphicsConfiguration is returned instead of the one for AWT.

The other bug with NewtCanvasAWT will have to be fixed too.

@Sven, if you have an idea, let me know.
Julien Gouesse | Personal blog | Website