public DynamicAtlas( RenderCoordinator coordinator, int width, int height, SurfaceFormat format, int spacing = 2, MipGenerator <T> mipGenerator = null ) { Coordinator = coordinator; Width = width; Height = height; Spacing = spacing; X = Y = Spacing; RowHeight = 0; _BeforePrepare = Flush; lock (Coordinator.CreateResourceLock) Texture = new Texture2D(coordinator.Device, width, height, mipGenerator != null, format); Pixels = new T[width * height]; if (mipGenerator != null) { MipBuffer = new T[(width / 2) * (height / 2)]; } GenerateMip = mipGenerator; MipLevelCount = Texture.LevelCount; Invalidate(); }
/// <summary> /// Replaces the built in Squared.Render mip generators with stb_image_resize /// </summary> public static void InstallGlobally() { var formats = new[] { MipFormat.Gray1, MipFormat.pRGBA, MipFormat.RGBA, MipFormat.pGray4, MipFormat.pRGBA | MipFormat.sRGB, MipFormat.RGBA | MipFormat.sRGB, MipFormat.pGray4 | MipFormat.sRGB, MipFormat.Vector4, MipFormat.Vector4 | MipFormat.sRGB, MipFormat.pVector4, MipFormat.pVector4 | MipFormat.sRGB, }; foreach (var format in formats) { MipGenerator.Set(format, Get(format)); } }