/// <summary>
 /// Cleans up the cubemap.
 /// </summary>
 public void Destroy()
 {
     _cubeTexture.Invalidate();
     _renderTarget.Invalidate();
     _sceneRenderState = null;
     _camera = null;
 }
        protected void _InitDynamic(int size, CubemapCamera camera)
        {
            if (!_cubeTexture.IsNull)
                return;

            _camera = camera;
            _sceneRenderState = new SceneRenderState();
            _renderTarget = ResourceManager.Instance.CreateRenderTargetCube(size);

            // resolve faces of cube texture for the xbox
            for (int i = 0; i < 6; ++i)
            {
                GFXDevice.Instance.Device.SetRenderTarget(0, _renderTarget.Instance, (CubeMapFace)i);
            }

            // reset render target
            TorqueEngineComponent.Instance.ReapplyMainRenderTarget();

            _cubeTexture = ResourceManager.Instance.CreateTextureCube(_renderTarget);
        }
        /// <summary>
        /// Initializes the cubemap.
        /// </summary>
        /// <param name="dynamic">True to make a dynamic cubemap, false to make a static cubemap.</param>
        /// <param name="size">The pixel size of the cubemap faces.</param>
        /// <param name="camera">The camera to use to render the cubemap faces.</param>
        public void Create(bool dynamic, int size, CubemapCamera camera)
        {
            if (dynamic)
                _InitDynamic(size, camera);
            else
            {
                for (int i = 0; i < 6; i++)
                {
                    string loadpath = TorqueUtil.ChopFileExtension(_cubeFaceFilenames[i].Trim());
                    _cubeFaces[i] = ResourceManager.Instance.LoadTexture(loadpath).Instance;
                }

                _InitStatic(ref _cubeFaces);
            }
        }