示例#1
0
        /// <summary>
        /// Loads the DDS texture.
        /// </summary>
        /// <param name="fileName">The name.</param>
        /// <param name="quality"></param>
        /// <returns></returns>
        protected override BaseTexture LoadDDSTexture(string fileName, TextureQuality quality)
        {
            var device = MyRender.GraphicsDevice;

            if (device == null || device.IsDisposed)
            {
                return(null);
            }

            //cannot use profiler because of multithreading
            //int loadDDSTextureBlock = -1;
            //VRageRender.MyRender.GetRenderProfiler().StartProfilingBlock("MyTexture2D.LoadDDSTexture", ref loadDDSTextureBlock);

            //MyRender.Log.WriteLine(string.Format("Loading DDS texture {0} ...", fileName), SysUtils.LoggingOptions.LOADING_TEXTURES);

            Texture loadedTexture = null;

            if (this.flags.HasFlag(TextureFlags.IgnoreQuality))
            {
                quality = TextureQuality.Full;
            }

            MyDDSFile.DDSFromFile(fileName, device, true, (int)quality, out loadedTexture);
            loadedTexture.Tag = this;

            if (!MathHelper.IsPowerOfTwo(loadedTexture.GetLevelDescription(0).Width) || !MathHelper.IsPowerOfTwo(loadedTexture.GetLevelDescription(0).Height))
            {
                throw new FormatException("Size must be power of two!");
            }

            //cannot use profiler because of multithreading
            //VRageRender.MyRender.GetRenderProfiler().EndProfilingBlock(loadDDSTextureBlock);
            return(loadedTexture);
        }
示例#2
0
        /// <summary>
        /// Loads the DDS texture.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="quality"></param>
        /// <returns></returns>
        protected override SharpDX.Direct3D9.BaseTexture LoadDDSTexture(string name, TextureQuality quality)
        {
            try
            {
                var device = MyRender.GraphicsDevice;
                if (device == null || device.IsDisposed)
                {
                    return(null);
                }

                if (this.flags.HasFlag(TextureFlags.IgnoreQuality))
                {
                    quality = TextureQuality.Full;
                }

                CubeTexture loadedTexture;
                MyDDSFile.DDSFromFile(name, device, true, (int)quality, out loadedTexture);
                loadedTexture.Tag = this;

                return(loadedTexture);
            }
            catch (FileNotFoundException)
            {
            }
            catch (Exception ddsException)
            {
                Debug.WriteLine(string.Format("W:Texture Cube (DDS) {0}", ddsException.Message));
            }

            return(null);
        }