private static void Update(TextureArray2dGL texArray, IEnumerable <NamedStream> resources) { var count = resources.Count(); if (2 > count) { return; } var bitmaps = from res in resources select new Bitmap(res.Stream); var first = bitmaps.First(); var levels = MathHelper.MipMapLevels(first.Width, first.Height); var internalFormat = TextureLoaderDrawing.SelectInternalPixelFormat(first.PixelFormat); texArray.SetFormat(first.Width, first.Height, count, levels, (SizedInternalFormat)internalFormat); var slice = 0; foreach (var bitmap in bitmaps) { var buffer = bitmap.ToBuffer(); var pixelFormat = TextureLoaderDrawing.SelectPixelFormat(bitmap.PixelFormat); texArray.Load(buffer, slice, pixelFormat, PixelType.UnsignedByte); ++slice; } texArray.Filter = TextureFilterMode.Mipmap; texArray.WrapFunction = TextureWrapFunction.ClampToEdge; }
private static ITexture2dArray TextureArrayImporter(IEnumerable <NamedStream> resources) { var texArray = new TextureArray2dGL(); Update(texArray, resources); return(texArray); }