Ejemplo n.º 1
0
        /// <summary>
        /// Loads the texture.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="path">The path.</param>
        /// <param name="loadedCallback">The loaded callback.</param>
        /// <param name="loadingMode">The loading mode.</param>
        /// <param name="flags">The flags.</param>
        /// <returns></returns>
        private static T LoadTexture <T>(string path, TextureLoadedHandler loadedCallback, LoadingMode loadingMode, TextureFlags flags) where T : MyTexture
        {
            using (TexturesLock.AcquireExclusiveUsing())
            {
                MyTexture texture;
                if (typeof(T) == typeof(MyTexture2D))
                {
                    texture = new MyTexture2D(path, GetLoadMethod(loadingMode), flags);
                }
                else if (typeof(T) == typeof(MyTextureCube))
                {
                    texture = new MyTextureCube(path, GetLoadMethod(loadingMode), flags);
                }
                else
                {
                    throw new ArgumentException("Unsupported texture type", "T");
                }

                if (loadedCallback != null)
                {
                    texture.TextureLoaded += loadedCallback;
                }

                switch (loadingMode)
                {
                case LoadingMode.Immediate:
                {
                    if (!texture.Load(Quality))
                    {
                        return(null);
                    }

                    break;
                }

                case LoadingMode.Background:
                {
                    LoadTextureInBackground(texture);
                }
                break;
                }



                if (m_textures.ContainsKey(path))
                {
                    m_textures[path] = texture;
                }
                else
                {
                    m_textures.Add(path, texture);
                }

                DbgWatchLoadedTextures();

                return((T)texture);
            }
        }
Ejemplo n.º 2
0
        public static void UnloadContent()
        {
            MyMwcLog.WriteLine("MyBackgroundCube.UnloadContent - START");
            MyMwcLog.IncreaseIndent();

            if (m_boxVertexBuffer != null)
            {
                m_boxVertexBuffer.Dispose();
                m_boxVertexBuffer = null;
            }

            if (m_textureCube != null)
            {
                MyTextureManager.UnloadTexture(m_textureCube);
                m_textureCube = null;
            }
            m_textureCube = null;
            m_loaded = false;

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyBackgroundCube.UnloadContent - END");
        }
Ejemplo n.º 3
0
 static void UpdateTexture()
 {     
     //  This texture should be in DDS file extension and must be DXT1 compressed (use Photoshop and DDS tool from NVIDIA)
     //  We don't use for it dxt compression from XNA's content processor because we don't want huge (over 100 Mb) files in SVN.
     m_textureCube = MyTextureManager.GetTexture<MyTextureCube>("Textures\\BackgroundCube\\Final\\" + GetFilename(), null, LoadingMode.Immediate);
 }