- Remove GL Late-initialization. GL is now set up when RocketFigure3d is constructed...
[debian/openrocket] / core / src / net / sf / openrocket / gui / figure3d / RocketFigure3d.java
index 3e3a98c49ecaf418c8167686969980b9e5a503cb..8df1e8508b84fc4cb7a9729751d1cf456af26afd 100644 (file)
@@ -6,8 +6,7 @@ import java.awt.Graphics2D;
 import java.awt.Point;\r
 import java.awt.Rectangle;\r
 import java.awt.RenderingHints;\r
-import java.awt.event.HierarchyEvent;\r
-import java.awt.event.HierarchyListener;\r
+import java.awt.SplashScreen;\r
 import java.awt.event.MouseEvent;\r
 import java.awt.geom.AffineTransform;\r
 import java.awt.image.BufferedImage;\r
@@ -86,20 +85,25 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
        public RocketFigure3d(Configuration config) {\r
                this.configuration = config;\r
                this.setLayout(new BorderLayout());\r
-\r
-               /**\r
-                * This achieves late GL initialization, so that if there is a crash\r
-                * it does not occur until user selects 3D view, so as to not render\r
-                * the application unusable.\r
-                */\r
-               addHierarchyListener(new HierarchyListener() {\r
-                       @Override\r
-                       public void hierarchyChanged(HierarchyEvent e) {\r
-                               log.verbose("GL - Calling initGLCanvas on hierarchy change");\r
-                               initGLCanvas();\r
-                               RocketFigure3d.this.removeHierarchyListener(this);\r
-                       }\r
-               });\r
+               \r
+               //Only initizlize GL if 3d is enabled.\r
+               if ( is3dEnabled() ){\r
+                       //Fixes a linux / X bug: Splash must be closed before GL Init\r
+                       SplashScreen splash = SplashScreen.getSplashScreen();\r
+                       if ( splash != null )\r
+                               splash.close();\r
+                       \r
+                       initGLCanvas();\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Return true if 3d view is enabled. This may be toggled by the user at\r
+        * launch time.\r
+        * @return\r
+        */\r
+       public static boolean is3dEnabled(){\r
+               return System.getProperty("openrocket.3d.disable") == null;\r
        }\r
        \r
        private void initGLCanvas(){\r