Exemple #1
0
        /**
         * Constructs a new <code>WorldWindowGLCanvas</code> on the default graphics device and shares graphics resources
         * with another <code>WorldWindow</code>.
         *
         * @param shareWith a <code>WorldWindow</code> with which to share graphics resources.
         *
         * @see GLCanvas#GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser,
         *      javax.media.opengl.GLContext, java.awt.GraphicsDevice)
         */
        public WorldWindowGLCanvas(WorldWindow shareWith)
        {
            base(Configuration.getRequiredGLCapabilities(), new BasicGLCapabilitiesChooser(), null);

            if (shareWith != null)
            {
                this.setSharedContext(shareWith.getContext());
            }

            try
            {
                this.wwd = ((WorldWindowGLDrawable)WorldWind.createConfigurationComponent(AVKey.WORLD_WINDOW_CLASS_NAME));
                this.wwd.initDrawable(this);
                if (shareWith != null)
                {
                    this.wwd.initGpuResourceCache(shareWith.getGpuResourceCache());
                }
                else
                {
                    this.wwd.initGpuResourceCache(WorldWindowImpl.createGpuResourceCache());
                }
                this.createView();
                this.createDefaultInputHandler();
                WorldWind.addPropertyChangeListener(WorldWind.SHUTDOWN_EVENT, this);
                this.wwd.endInitialization();
            }
            catch (Exception e)
            {
                String message = Logging.getMessage("Awt.WorldWindowGLSurface.UnabletoCreateWindow");
                Logging.logger().severe(message);
                throw new WWRuntimeException(message, e);
            }
        }