/// <summary> /// Loads a texture from a stream. /// </summary> /// <param name="stream">Stream to load texture from.</param> /// <returns>Texture object.</returns> public ITexture2d Load(Stream stream) { Filter resizeFilter = Filter.None; if (autoResize) { resizeFilter = autoResizeFilter; } // HACK - will be replaced by a texture quality handler Format f = format; int w = 0; int h = 0; SurfaceDescription desc = new SurfaceDescription(0, 0, Format.A8R8G8B8); if (textureQuality != 1.0f) { desc = textureLoader.GetSurfaceDescription(stream); } if (textureQuality < 0.7f) { f = Format.Dxt5; } if (textureQuality < 0.1f) { f = Format.Dxt1; } if (this.autoResize == false) { mipLevels = 1; } // HACK - will be replaced by a texture quality handler ITexture2d tex = textureLoader.Load(stream, w, h, mipLevels, f, resizeFilter, this.mipMapFilter, TextureUsage.Normal); textures.Add(new WeakReference(tex)); return(tex); }
//--------------------------------------------------------------- #endregion //--------------------------------------------------------------- //--------------------------------------------------------------- #region Initialisation //--------------------------------------------------------------- /// <summary> /// Creates an instance of a SubTexture. /// </summary> /// <param name="textureCoordinates">New texture coordinates relativ to parent texture [0;1].</param> /// <param name="parentTexture">The texture to create the subTexture from.</param> public SubTexture(RectangleF textureCoordinates, ITexture2d parentTexture) { this.parentTexture = parentTexture; this.textureCoordinates = CalcSubCoordinates(textureCoordinates, parentTexture.TextureCoordinates); this.imageDescription = CalcImageDescription(); }