public void Dispose()
 {
     ReflectionTexture.Clear();
     BgTexture.Clear();
     SkyTexture.Clear();
     Wallpaper.Clear();
 }
        /// <summary>
        /// Read texture data and bg color from environments
        /// </summary>
        public void HandleEnvironments(RenderEnvironment.Usage usage)
        {
            SimulatedEnvironment simenv;

            switch (usage)
            {
            case RenderEnvironment.Usage.Background:

                if (BackgroundEnvironment != null)
                {
                    simenv = BackgroundEnvironment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        BgColor = simenv.BackgroundColor;
                    }
                    BitmapConverter.EnvironmentBitmapFromEvaluator(BackgroundEnvironment, BgTexture, Gamma);
                }
                else
                {
                    BgColor = Color.Empty;
                    BgTexture.Clear();
                }
                break;

            case RenderEnvironment.Usage.Skylighting:
                if (SkylightEnvironment != null)
                {
                    simenv = SkylightEnvironment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        SkyColor = simenv.BackgroundColor;
                    }
                    BitmapConverter.EnvironmentBitmapFromEvaluator(SkylightEnvironment, SkyTexture, Gamma);
                }
                else
                {
                    SkyColor = Color.Empty;
                    SkyTexture.Clear();
                }
                break;

            case RenderEnvironment.Usage.ReflectionAndRefraction:
                if (ReflectionEnvironment != null)
                {
                    simenv = ReflectionEnvironment.SimulateEnvironment(true);
                    if (simenv != null)
                    {
                        ReflectionColor = simenv.BackgroundColor;
                    }
                    BitmapConverter.EnvironmentBitmapFromEvaluator(ReflectionEnvironment, ReflectionTexture, Gamma);
                }
                else
                {
                    ReflectionColor = Color.Empty;
                    ReflectionTexture.Clear();
                }
                break;
            }
        }