/// <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, string contentDir, TextureLoadedHandler loadedCallback, LoadingMode loadingMode, TextureFlags flags) where T : MyTexture { MyTexture texture; if (TexturesWithIgnoredQuality.Contains(Path.Combine(contentDir, path))) { flags |= TextureFlags.IgnoreQuality; } if (typeof(T) == typeof(MyTexture2D)) { texture = new MyTexture2D(contentDir, path, GetLoadMethod(loadingMode), flags); } else if (typeof(T) == typeof(MyTextureCube)) { texture = new MyTextureCube(contentDir, 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(MyRenderConstants.RenderQualityProfile.TextureQuality, (flags & TextureFlags.CanBeMissing) > 0)) { return(null); } break; } case LoadingMode.Background: { LoadTextureInBackground(texture); } break; } lock (m_textures) { m_textures[Path.Combine(contentDir, path)] = texture; DbgWatchLoadedTextures(); } return((T)texture); }
public static double GetTextureSizeInMb(MyTextureCube texture) { return 6 * CalculateTextureSizeInMb(texture.Format, texture.Size, texture.Size, texture.LevelCount); }
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. if (string.IsNullOrEmpty(Filename)) m_textureCube = null; else m_textureCube = MyTextureManager.GetTexture<MyTextureCube>(Filename, "", null, LoadingMode.Immediate); }
public override void UnloadContent() { MyRender.Log.WriteLine("MyBackgroundCube.UnloadContent - START"); MyRender.Log.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; MyRender.Log.DecreaseIndent(); MyRender.Log.WriteLine("MyBackgroundCube.UnloadContent - END"); }