/// <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 = MyMinerGame.Static.GraphicsDevice; if (device == null || device.IsDisposed) { return(null); } //cannot use profiler because of multithreading //int loadDDSTextureBlock = -1; //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyTexture2D.LoadDDSTexture", ref loadDDSTextureBlock); MyMwcLog.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 (!MyUtils.IsPowerOfTwo(loadedTexture.GetLevelDescription(0).Width) || !MyUtils.IsPowerOfTwo(loadedTexture.GetLevelDescription(0).Height)) { throw new FormatException("Size must be power of two!"); } //cannot use profiler because of multithreading //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(loadDDSTextureBlock); return(loadedTexture); }
/// <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 = MyMinerGame.Static.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); }